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

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


    }


});
  • The function will call after any field update not a specific meta field. – Lakhan Pal Singh Oct 12 '17 at 12:03
  • .yes it's that. – mmm Oct 12 '17 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' );
  • 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 Oct 12 '17 at 16:50
  • Hello Mr Ajay i was try your code but it is not working according to my requirment – Lakhan Pal Singh Oct 13 '17 at 5:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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