• Hi! Can you let me know how to make content visible by role please? I have tried various expressions but none seem to work. Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi there this worked for me. thought i should share

    current_user_can(‘rolename’)

    or for multiple

    current_user_can(‘rolename’) || current_user_can(‘rolename’) || current_user_can(‘rolename’)

    Hi there, the above seems like the option I am looking for but I have three modules one set to user logged in and the other to user not logged in, if I add a third option to a specific user role wholesale_customer I guess the logged in user one will also trigger with this one. I need it to be only shown to wholesale_customers but the other one for logged in users not to be displayed any guidance be greatly appreciated.

    Plugin Author Jonathan Horowitz

    (@jhorowitz)

    Hi @mhayden,

    Please try is_user_logged_in() && !current_user_can('wholesale_customers') for logged in users that are not wholesale customers.

    Thanks @antheaancalade for the assistance ??

    Hi Jonathan,

    Thank you for the above and I tested it and it does seem to be the solution. However since then I am unable to access my divi library items fully, so I have gone in in safe mode and added my three rows of products for each user, when I now exit the visual builder the page I just added the content visability code to then whites out to a white page and inaccessible, if I then disable the content visibility plugin I can see the page with all three rows rather but not the selected row based on user status, I am running late on a project and your plugin looks like the answer to my prayers but at the moment not seeming to do the job.

    Any help would be gratefully received.

    Hi Jonathan,

    I tried to use the following

    Retail logged in not Wholesale
    is_user_logged_in() && !current_user_can(‘wholesale_customer’)

    Normal User
    !is_user_logged_in()

    Wholesale
    is_user_logged_in() && current_user_can(‘wholesale_customer’)

    As just using
    current_user_can(‘wholesale_customer’) seemed to be what was causing the problem as adding the three above codes one at a time works and the pages can be saved and are not whited out and can be saved ok.

    Now when I am logged in as non wholesale user I see the correct row.

    If I am logged in as a wholesale customer I see all three.

    If I am not logged in I see two rows, so I appear to be making some progress as far as the pages are now saving and visible and the plugin appears to be working am I using the wrong code anywhere above?

    Appreciate any feedback.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Visibility by role’ is closed to new replies.