• Resolved 22-7ths

    (@22-7ths)


    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter 22-7ths

    (@22-7ths)

    (bump) been a few days. Still have not resolved this. thanks to any who can help..

    Thread Starter 22-7ths

    (@22-7ths)

    Answer was simply that priority was too low. 10 is default. I am using ‘WP Member’ plugin fields and they also use a priority of 10. So it wasn’t picking up new values on just those fields. Increasing priority lets them pick up changed values. (Thanks Chad)

    Change
    add_action ( 'profile_update', 'myplugin_admin_update', 10, 2 );
    to
    add_action ( 'profile_update', 'myplugin_admin_update', 11, 2 );

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get user profile data AFTER admin update/submit’ is closed to new replies.