The MU forums have moved to WordPress.org

catch action of creating new blog when user register (5 posts)

  1. leticia5959
    Member
    Posted 14 years ago #

    Hello

    I made a plugin that save to a log the actions of creating a new blog.

    When users, in admin panel (/wp-admin/wpmu-blogs.php), creates a new blog the action is catched and save successfully using the follow code:

    add_action("wpmu_new_blog", 'handle_action_wpmu_new_blog', 1, 2;
    
    function handle_action_wpmu_new_blog($blog_id, $user_id) {
    // code to save in the log that the user $user_id creates a new blog
    }

    The problem is when:

    1. user register and creates a blog in the same time (using register option, /wp-signup.php)
    2. the user click on the activation link that he/she receives
    3. the user get the notification of successfully activation of user account and blog

    After the previous steps, my function (handle_action_wpmu_new_blog) isn't called.

    Thanks in advanced, any help will be appreciated.

  2. tdjcbe
    Member
    Posted 14 years ago #

    There's a missing ) mark at the end of your add_action line. Is that missing from your code as well or is it just a typo here?

  3. leticia5959
    Member
    Posted 14 years ago #

    Is a typo, thanks for report it.

    The code is:

    add_action("wpmu_new_blog", 'handle_action_wpmu_new_blog', 1, 2);
    
    function handle_action_wpmu_new_blog($blog_id, $user_id) {
    // code to save in the log that the user $user_id creates a new blog
    }
  4. leticia5959
    Member
    Posted 14 years ago #

    Well, seems like WordPress isn't loading my plugin before do_action wpmu_new_blog

    The way I fix this is calling my plugin file before the do_action:

    1. edit the file /wp-includes/wpmu-functions.php
    2. modify the function
      function wpmu_activate_signup($key) {
    3. add the line to include the plugin:
      include_once pathinfo(__FILE__,PATHINFO_DIRNAME) . '/../wp-content/plugins/my_plugin/my_plugin';
      before the line:
      do_action('wpmu_activate_blog', $blog_id, $user_id, $password, $signup->title, $meta);

    I really dislike modify core code, please, if anyone has other idea, will be welcome.

  5. MAHABUB
    Member
    Posted 14 years ago #

    Dear leticia5959,

    this can solve your problem....!!

    add_action("wpmu_new_blog", 'handle_action_wpmu_new_blog', 1, 2);
    add_action("wpmu_activate_blog", 'handle_action_wpmu_new_blog', 1, 2);
    
    function handle_action_wpmu_new_blog($blog_id, $user_id) {
    // code to save in the log that the user $user_id creates a new blog
    }

    Thanks
    Mahabub

About this Topic

  • Started 14 years ago by leticia5959
  • Latest reply from MAHABUB