I’m not sure if this is what you mean:
If you want you assign a certain user role (e.g. contributor, editor or subsciber), to users of a particular level, than you can add something like this to your funtion.php file:
<?php
/*
This code will make members signing up for membership level #2 premium:memeber and make them normal bbp_participant when they cancel.
*/
function my_pmpro_after_change_membership_level($level_id, $user_id)
{
if($level_id == 2)
{
//New member of level #2.
$wp_user_object = new WP_User($user_id);
$wp_user_object->set_role('contributor');
}
else
{
//Not a member of level #2
$wp_user_object = new WP_User($user_id);
$wp_user_object->set_role('subscriber');
}
}
add_action("pmpro_after_change_membership_level", "my_pmpro_after_change_membership_level", 10, 2);
?>
It will assign contributor role to members of level 2, and subscriber role to member of other levels.
I use this code to assign a certain role to members of level 2 and and a different role to the other level.
Hope this is what you’re looking for…
Woutm got it right. (Thanks!)
FWIW, here is similar code for assigning the “author” role from our website:
http://www.paidmembershipspro.com/2011/10/give-new-members-author-role/
I’d like to set two membership levels to ‘Contributor.’ The code above works for converting one level, but I can’t seem to get it to work for two.
Appreciate the help.
I think you can simply change the IF condition.
You should look up the level id`s of the membership levels you want to set to ‘Contributor’ and add them in the IF statement.
e.g. for level id 2 and 3:
if($level_id == 2 || $level_id == 3 )
Thank you.
I’m not sure what I did wrong. Thought I had tried your solution, but obviously missed something. Now it works.