I have two user role
1)student
2)paid student
I have situation after the payment i am changing role student to paid student it work good but here i have also change the forum role programmatically to participant for paid student here . How do i change forum role programmatically using query, function anything.
Below code i have used to change user roles programmatically it works good but i am stuck d in changing forum role. i am looking something like this.
$user_id = get_current_user_id();
$oldrole=implode(', ', $user_id->roles);
if($oldrole=="student")
{
$u = new WP_User($user_id);
// Remove role
$u->remove_role('student');
$newrole="paid_student";
// Add role
$u->add_role( $newrole );
}
Finally i have got the answer. Bellow are the step.
1) Get user current user id.
2)set new user forum role you wish to change
3)fire function.
now check your user in back end and see forum user role.
Full snippet code