Forums

[resolved] profile_update action Missing argument 2 (3 posts)

  1. dadkins20
    Member
    Posted 11 months ago #

    I'm trying to create a plugin that subscribes and unsubscribes users from our email system and I'd like my function to run right after the user updates their profile. Here is the erroneous part of my code:

    function subscribe_unsubscribe($uid, $old_user_data) {
    print_r($old_user_data);
    }
    add_action('profile_update', 'subscribe_unsubscribe');

    Warning: Missing argument 2 for subscribe_unsubscribe() in /var/www/public_html/wp-content/plugins/user-registration/subscribe.php on line 46

    According to the docs here (http://codex.wordpress.org/Plugin_API/Action_Reference/profile_update) and the code in user.php this should work. Not sure what I'm doing wrong. Any help would be appreciated.

  2. Otto
    Tech Ninja
    Posted 11 months ago #

    Change your add action line to this:

    add_action('profile_update', 'subscribe_unsubscribe', 10, 2);

    When an action receives more than one argument, you have to specify the number of arguments to send it.

  3. dadkins20
    Member
    Posted 11 months ago #

    Thanks, that worked perfectly.

Reply

You must log in to post.

About this Topic