I have code placed where when a user changes their level, it displays in BuddyPress activity stream. But when this is posted to BuddyPress activity it shows as: USER has become a s2member_level2
I am trying to get the “s2member_level2” part (the role) to display as the label (have force labels set in S2Member settings). That didn’t work, so I also tried to change the role name in User Role Editor to no avail.
How do I get the role name to display as the modified name label?
Thanks.
Here is the code I am using to display role changes:
function buddydev_record_role_change_activity( $user_id, $role, $old_roles ) {
$role = get_role( $role );
if ( ! $role ) {
return ;
}
$action = sprintf( '%s has become a %s', bp_core_get_userlink( $user_id ), $role->name );
xprofile_record_activity( array(
'user_id' => $user_id,
'action' => $action,
'content' => '',
'type' => 'role_changed'
) );
}
add_action( 'set_user_role', 'buddydev_record_role_change_activity', 10, 3 );