Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have created a custom user meta field, and that value is being used to get data from an external API and display it on the user profile page. On admin pages I have used the following code to make sure that when an administrator account views a user profile, s/he can view the data displayed from the API.

And then calling the API, and retrieving the cached data from a transient prefixed by the user id yadadada. This all works perfectly, and the data displays properly. But if the administrator then tries to update another user's account custom meta field despite the fact that I pass the correct userid to the update_user_meta function, meta value does not update. Below is the code for the update function.

function af_askFRED_update_fencer_field() {
    $user = wp_get_current_user();
    $userid = $user->ID;

    if (current_user_can('delete_users') && isset($_GET['user_id'])) {
        $userid = $_GET['user_id'];
    }

    $usfaID = $_POST['af_askFRED_usfaID'];
    update_user_meta($userid, 'af_askFRED_usfaID', $usfaID);
    delete_transient($userid.'AF_USFA_KEY');

}

add_action('personal_options_update', 'af_askFRED_update_fencer_field');

NOTE: If I update any other profile field it works perfectly.

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.