• Resolved miloudbelko

    (@miloudbelko)


    I need to retrieve the Role Title of my users but the code um_user( ‘role_name’ ) does not work.

    I tried adding the snippet UM support provided to @mfrie01 who had the same problem but it did not work for me. Here is the snippet provided by UM support:

    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;
    }

    I also try to use the function get_role_name() but, unfortunately, this did not work either.

    Is there a way to retrieve this information programatically in versions 2.0.23+ of the plugin or can I only use the role ID with the function um_user( ‘role’ ) which still works?

Viewing 1 replies (of 1 total)
  • Thread Starter miloudbelko

    (@miloudbelko)

    I have just found the way to do it:

    $role_name = UM()->roles()->get_role_name(um_user( ‘role’ ));

    Hope it can help someone else 😉

    • This reply was modified 7 years, 4 months ago by miloudbelko.
Viewing 1 replies (of 1 total)

The topic ‘Role Title’ is closed to new replies.