Support Forum ยป User Profile

Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • in reply to: โœ…Change User Role #19800
    Bill PhelpsBill Phelps
    Participant

    OK. This seems to be working now. For anyone else interested...

    • The 'role' select field is now created only when is_admin() == false - which fixes the duplication on the 'Edit User page.
    • WordPress doesn't know anything about this 'role' select field - at least, not in relation to a user's roles and capabilities. Hence the need to use action rwmb_profile_after_process to find the just-saved 'role' meta_value in wp_usermeta and copy it across to 'wp_capabilities', which is where WordPress expects to find it.

      For the same reason, whenever we display the frontend form we need to ensure that the 'role' meta_value reflects the contents of 'wp_capabilities' - in case the user's role has been updated via the 'Edit User' page which doesn't update the 'role' meta_value.

    • I'm using filters rwmb_user_login_html and rwmb_user_email_html to populate fields 'user_login' and 'user_email' based on $user_id. (For some reason, the corresponding rwmb_{$field_id}_field_meta filters don't seem to work for this.) I've also specified 'user_login' as 'disabled' => true, 'readonly' => true, 'save_field' => false - because it's not supposed to be changed.

    Hope this helps someone.

    in reply to: โœ…Change User Role #19765
    Bill PhelpsBill Phelps
    Participant

    I've now hit a problem with 'user_login' and 'user_email' on my front-end profile page.

    All the other fields display the correct info for $user_id, but 'user_login' and 'user_email' are showing my own (ie: current_user) data.

    When I update the form, I get the error message: "Sorry, that email address is already used!"
    And also (bizarrely): "Your information has been successfully submitted. Thank you."

    All the other fields update OK, but 'user_login' and 'user_email are unchanged and 'role' just seems to affect the meta_value of 'role' in 'wp_usermeta', without touching the meta_value of 'wp_capabilities'. I'm guessing this may get resolved once I get the 'user_login' and 'user_email' problem fixed.

    One other issue I have is that there are now two 'role' fields showing on the usual backend 'Edit User' page.

    Any help you can give will be greatly appreciated, of course ๐Ÿ™‚

    in reply to: โœ…Change User Role #19760
    Bill PhelpsBill Phelps
    Participant

    Thanks - that's a very speedy and useful reply!

    I think I've got enough here to make progress. Rather than manually adjusting user_id, I'll try including $user_id within do_shortcode()...

    $form = "[mb_user_profile_info id='user_profile_role' user_id={$user_id}]";
    echo do_shortcode( $form );

    I'll let you know how I get on ๐Ÿ™‚

Viewing 3 posts - 1 through 3 (of 3 total)