The MU forums have moved to WordPress.org

action hook triggered by createBlog? (8 posts)

  1. debrouille
    Member
    Posted 17 years ago #

    I'm looking for a way to call my plugin function whenever a new blog is created. I tried:
    add_action('createBlog', 'myFunction');
    which doesn't work. No hook programmed for createBlog?

    Do i need to insert the call to my function in the createBlog()? This whould be overwritten on the next WPMU-update, wouldn't it?

    Thanks for any hint!

  2. drmike
    Member
    Posted 17 years ago #

    Why not just stick in an 'include' within the createBlog function? Or is this going to be a plugin that you release?

  3. debrouille
    Member
    Posted 17 years ago #

    Thank you for your answer drmike!

    <quote>Or is this going to be a plugin that you release?</quote>
    Well at the end i'd like to release it, but that's not the priority right now. It's gonna be an intro page for multiblogs sites: overview over the blogs, last posts, newest blogs etc...

    Yes i can 'include' it, good idea. Nevertheless i'll have to reinsert this line (and there might be more such changes) after each update...

    I have a similar question again: i'd like to change the wp-newblog.php to change the blog creation process. How should i do that, again without changing core code? I'd like to have a own my-newblog.php
    When i place my my-newblog.php in wp-inst, near the original wp-newblog.php i can't call it: calling mydomain/my-newblog.php instead of mydomain/wp-newblog.php doen't work as WP remaps this URL to mydomain/my-newblog/

    How should this be done? Plugin? Declare this new file somewhere?

  4. markmansour
    Member
    Posted 17 years ago #

    The action 'wpmu_new_blog' is called when a new blog is created, so maybe that will do the trick for you? Not sure. I have also changed the login page to include more fields, but I've just hacked the main code. I think I'm going to go back and try to write a filter that adds in the new fields. Dunno if it will work, I need to look at some other plugins to get some ideas.

    Have you progressed with any of these items at all?

  5. samchng
    Member
    Posted 17 years ago #

    "I have also changed the login page to include more fields, but I've just hacked the main code."

    Example of fields added? Do you store them into the database?

    On the other hand, I have been trying to do a checkbox for Terms and Conditions, but it has a warning when it's unchecked but doesn't create a blog if it's ticked. Tsk tsk....

  6. markmansour
    Member
    Posted 17 years ago #

    I've added extra fields capture address information of a user and added them into the wp_users table (I created custom columns), but this was a bad move. I'm going to alter my code to put this data into the wp_usermeta table. So, I'm going to fix where I put the data, but how I put the extra fields on the screen in a 'plugin' manner is still to be solved.

  7. debrouille
    Member
    Posted 17 years ago #

    "Example of fields added? Do you store them into the database?"

    and

    "I've added extra fields capture address information of a user and added them into the wp_users table (I created custom columns), but this was a bad move. I'm going to alter my code to put this data into the wp_usermeta table."

    Well, i've added a topic for each new blog using the <blogname>_options table.
    I used the add_blog_option(), which i added in the in the createBlog() function in wp-inst/wp-includes/wpmu-functions.php:
    add_blog_option( $blog_id, 'topic', $topic );
    where $topic is the value i got from the posted form (so of course i also had to edit the wp-inst/wp-newblog.php)

    The nice thing is that i don't have to create any new table or column and i can edit this new option like all other options in the 'Site Admin > Blogs > [choose a blog] edit' page.

  8. markmansour
    Member
    Posted 17 years ago #

    I like that solution, but it is suitable for site info rather than user info. I'm associating addresses with user so I need to store this info in the usermeta table. The downside is that I now have to write an admin page for users to edit this info.

About this Topic

  • Started 17 years ago by debrouille
  • Latest reply from markmansour