WordPress.org

Ready to get started?Download WordPress

Forums

Feature Request - Missing Function "get_role_name" (2 posts)

  1. Blackbam
    Member
    Posted 2 years ago #

    Searching the function reference, I was not able to find a function for getting the role name (display name) of a user role.

    I finally figured out a way how to get it, which took me half an hour to find out:

    $roles = new WP_Roles();
    $allroles = $roles->get_names();
    echo $allroles[$role]; // $role like 'administrator','author','custom',...

    There should be a function for this in the Function Reference. Please correct me if I am wrong or there is a better way.

Topic Closed

This topic has been closed to new replies.

About this Topic