• Resolved Megajairus

    (@megajairus)


    I’m trying to build an application to a website that will allow members to place an order. I need to fetch the member’s role or membership level to give a price estimate. Does this plugin have short code or other means of me fetching that information?

    https://ww.wp.xz.cn/plugins/members/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Roles are built into WordPress. So, all the relevant functions are built into WordPress. Members merely provides the UI.

    So, you can get a user’s roles via:

    $user = new WP_User( $user_id );
    
    $roles = (array) $user->roles;

    You just need to pass in the user ID. It’ll be an array of roles and will return all roles that a user has.

    Thread Starter Megajairus

    (@megajairus)

    Extremely helpful. Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Fetch role or membership level’ is closed to new replies.