Forum Replies Created
-
AuthorPosts
-
Bill Phelps
ParticipantOK. 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_processto find the just-saved 'role' meta_value inwp_usermetaand 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_htmlandrwmb_user_email_htmlto populate fields 'user_login' and 'user_email' based on$user_id. (For some reason, the correspondingrwmb_{$field_id}_field_metafilters 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.
Bill Phelps
ParticipantI'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 ๐
Bill Phelps
ParticipantThanks - 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 ๐
- The 'role' select field is now created only when
-
AuthorPosts