WordPress is the software behind buddyPress.
If you need custom roles&capabilities on your site, you can add roles programatically as explained on your mentionned tutorial. If it works, site admin can attribute one of the additionnal role to members, within admin.
BuddyPress, at this time, handles only member types. A member type is not a role or a capability à la WordPress, but only a way to sort better your members. In other words, a kind of a member category.
To handle such behave from front-end while registering, you can associate a xprofile field value with an existing WP role. See here for a solution (untested) provided a few month ago.
https://buddypress.org/support/topic/how-to-assign-a-wp-user-role-based-on-a-registration/#post-232887
Add snippet to your child theme functions.php or into bp-custom.php and give it a try.
yay, that was what i was looking for. Dont know why i didnt find it myself – sorry
Give feedback here if it worked for you.
Yes it worked for me, thanks again. Here is the snippet which i am using in my functions.php
:
add_action('bp_core_activated_user', 'bp_custom_registration_role',10 , 3);
function bp_custom_registration_role($user_id, $key, $user) {
$userdata = array();
$userdata['ID'] = $user_id;
$userdata['role'] = xprofile_get_field_data('Ich bin', $user_id);
if ($userdata['role'] == 'Dienstleister') {
$userdata['role'] = 'dienstleister';
}
elseif ($userdata['role'] == 'Kunde') {
$userdata['role'] = 'kunde';
}
//only allow if user role is my_role
if (($userdata['role'] == "dienstleister") or ($userdata['role'] == "kunde")) {
wp_update_user($userdata);
}
}
Yep ! Glad yo got it. Thank you for feedback. 😉