I’m looking for the hook that fires when a user’s information are updated. Specifically, I want to update a post with the value of a custom profile field (in my example info) everytime that user’s profile is updated.

I tried the profile_update hook, but it doesn’t seem to fire:

add_action( 'profile_update', 'add_info_to_post' );
function add_info_to_post( $user_id ) {

        $info=get_user_meta($user_id,'info',true);

        //get all items of that user
        $args=array(
                'author' => $user_id,
                'post_type' => 'item',
        );

        $items=get_posts($args);            
        foreach ($items as $item){
        update_post_meta($item->ID,'user_info',$info);
        }
}

Any suggestions how to make this work?

EDIT:
Maybe I should mention that I access the users’ profile pages through the backend..

1
1

From Codex: Plugin API – Action Reference – profile_update:

Note: This hook is not used on user edit/profile pages. To hook into the admin’s user edit pages, use the hook edit_user_profile_update which is located in /wp-includes/user-edit.php instead.

From Codex: Plugin API – Action Reference – edit_user_profile_update:

This hook only triggers when a user is viewing another user’s profile page (not their own). If you want to apply your hook to ALL profile pages (including the current user) then you also need to use the personal_options_update hook.

Leave a Reply

Your email address will not be published. Required fields are marked *