1

I have a membership site I want to call a function when any fields of user will update from any where of site.

I was used this function but it is not Running:

$current_user = wp_get_current_user();
$user_id = $current_user->ID;
 function update_extra_profile_fields($user_id) {
     if ( current_user_can('edit_user',$user_id) )
         myfunction();
 }

Please help me

2

2 Answers 2

0

the action update_user_meta is done before the value is saved in database

you can try this code

add_action("update_user_meta", function ($meta_id, $user_id, $meta_key, $_meta_value) {


    if (current_user_can('edit_user', $user_id)) {

        // do something


    }


});
2
  • The function will call after any field update not a specific meta field. Commented Oct 12, 2017 at 12:03
  • .yes it's that.
    – mmm
    Commented Oct 12, 2017 at 12:20
0
// this action run when the your user meta updated.
add_action( 'personal_options_update', 'your_custom_function_name' );

// this action run when the other user meta updated.
add_action( 'edit_user_profile_update', 'your_custom_function_name' );
2
  • Mr Ajay, try adding a bit more content here. This is the right tag but the question is not actually answered by what you've submitted.
    – rudtek
    Commented Oct 12, 2017 at 16:50
  • Hello Mr Ajay i was try your code but it is not working according to my requirment Commented Oct 13, 2017 at 5:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.