Get user profile data AFTER admin update/submit
-
I am trying push user update fields to an api via user profile edit or admin user edit.
I have successfully allowed user to update their own profile and have it also update the remote api with same (new) update data.
I have had less success getting the admin side to work correctly.
if ( is_admin () ) { add_action ( 'profile_update', 'myplugin_admin_update', 10, 2 ); //add_action ( 'edit_user_profile_update', 'myplugin_admin_update', 10, 2 ); // ^ Fires before form submit. Don't think I can use it. ... } function myplugin_admin_update ($user_id, $old_user_data) { $user_meta = array_map( function( $a ){ return $a[0]; }, get_user_meta( $user_id ) ); ... }
I then basically send $user_meta off to another routine to be processed and sent. That part works fine.
The problem is $user_meta is ‘old’ data. The data I pull from DB is not the new submitted data but the pre-update data – seemingly contrary to description in api codex? I understand the hook delivers ‘$user_old_data’ but I am not interested in that – just when it fires. I only need a hook that fires immediately after the admin updates a user. Not before.
Codex:
profile_update This hook allows you to access data for a user immediately after their database information is updated
What am I doing wrong? I get ‘old data’ when i query DB on this hook.
- The topic ‘Get user profile data AFTER admin update/submit’ is closed to new replies.