• CAD

    (@carlos1984)


    Hi!
    I really need some help here. I’ve checked https://rocketgeek.com/plugins/wp-members/docs/api-functions/ and looked at “wpmem_user_has_role()”.

    I have created different memberships(products) in this plugin like Gold, silver, bronze.
    In admin under “memberships” I can see the slug gold I created(Product attribute).

    Now in my code I want to do something like:

    if ( wpmem_user_has_role( ‘gold’ ) ) {
    //DO STUFF <div>SHOW MY CONTENT</div>
    }

    or
    if ( wpmem_logged_in_product( ‘gold’ ) ){
    //DO STUFF <div>SHOW MY CONTENT</div>
    }

    I cant get it working??
    There must be a way to check WHAT role/slug a user currently have as logged in and be able to show different content based on that. The issue here is that I want to show hide only a part of the content/div for specific users.

    Anybody plz help!!

    • This topic was modified 3 years, 1 month ago by CAD.
Viewing 1 replies (of 1 total)
  • Plugin Author Chad Butler

    (@cbutlerjr)

    You are mixing the concept of roles and memberships, but they are two different things.

    To clear up some possible confusion, “roles” are a WP defined construct. “Memberships” are not roles.

    wpmem_user_has_role() ONLY checks for roles, not memberships.

    What you are looking for is wpmem_user_has_access() which can check if a user has a specific membership (i.e. wpmem_user_has_access( 'gold' )). See: https://rocketgeek.com/plugins/wp-members/docs/api-functions/wpmem_user_has_access/ for documentation.

Viewing 1 replies (of 1 total)
  • The topic ‘Check if a specific member role is logged in’ is closed to new replies.