• In the previous version I could get the role slug. Now the code doesn’t return anything.
    If I run this code I get a User ID and a User Name, but no role. How do I get the role?

    	global $ultimatemember;
    	$user_id = get_current_user_id();
    	um_fetch_user( $user_id );
    	$role = um_user('role_name');
    	$display_name = um_user('display_name');
    	ob_start( );
    	echo "<p>User ID: $user_id</p>\n";
    	echo "<p>User Name: $display_name</p>\n";
    	echo "<p>Role: $role</p>\n";
    	return ob_get_clean( );
    
Viewing 1 replies (of 1 total)
  • @mfrie01

    UM does not update role anymore.

    This snippet may be usefull:
    add_filter( ‘um_user_permissions_filter’, ‘um_user_add_metakey’, 10, 2 );
    function um_user_add_metakey( $role_meta, $user_id ) {
    $role = UM()->roles()->get_um_user_role( $user_id );
    update_user_meta( $user_id, ‘role’, UM()->roles()->get_role_name($role) );
    return $role_meta;
    }

Viewing 1 replies (of 1 total)
  • The topic ‘um_user(‘role_name’) Doesn’t Work’ is closed to new replies.