@rune-kragh-rasmussen
10 years, 2 months ago
Can you please explain what you did to solve it. I desperately would like to know how to let members choose their user roles on registration.
I have created a new xprofile group called ‘User Role’, with the following values (‘Editor’, ‘Contributor’, ‘Admin’ and ‘Subscriber’.
After this I pasted the following code into “bp-custom.php”:
function register_role($user_id) { $user_role = strtolower(xprofile_get_field_data('User Role', $user_id)); switch($user_role) { case "Editor": $new_role = 'editor'; break; case "Contributor": $new_role = 'contributor'; break; case "Admin": $new_role = 'admin'; break; case "Subscriber": $new_role = 'subscriber'; break; } wp_update_user(array( 'ID' => $user_id, 'role' => $new_role )); } add_action( 'user_register', 'register_role');
What more do i need to do to make it work?