• Hello!
    I am needing to get the user roles including other roles the plugin creates to show a custom page. I have looked through your documentation but can’t find a function to get the data. Please guide me how to get this data.
    Thank you!

Viewing 1 replies (of 1 total)
  • Plugin Author Vladimir Garagulya

    (@shinephp)

    Try code below as a starting point. It uses get_user_by() function to load user object by user ID:

    
    $user = get_user_by('id', 15 );
    if ( empty( $user ) ) {
         return;
    }
    $user_roles = array();
    $roles = wp_roles();
    foreach( $user->roles as $role ) {
       $user_roles[] = $roles->role_names[$role];
    }
            
    $output = implode( ', ', $user_roles );
            
    echo $output;
    
Viewing 1 replies (of 1 total)
  • The topic ‘How to get other roles by user in custom page?’ is closed to new replies.