• I don’t want to show your plugin to users who visit or subscribe to my site, is there a way to do this? I only want to show your plugin to admins and store vendors.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Anna Bansaghi

    (@annabansaghi)

    Hello @niyht ,

    Unfortunately, the plugin does not provide a nice option for that, but I will work on this in the next version of the plugin.

    In the meantime a possible workaround would be:
    1. Adding role names as classes to the body element
    2. Adding additional CSS to the theme for hiding the bar for specific roles.

    In details:

    1. By adding the following snippet to the current theme’s functions.php file it is possible to add more classes to the body HTML element:

    add_filter( 'body_class', 'my_body_class' );
    function my_body_class( $classes ) {
        $roles = wp_get_current_user()->roles;
        $classes = array_merge( $classes, $roles );
        return $classes;
    }

    It is important to check that there is no name conflict between the original class names and the new ones generated from the role names.

    2. On the theme customization page we can add the following additional CSS:

    body:not(.administrator) #mobile-contact-bar,
    body:not(.vendor-admin) #mobile-contact-bar {
        display: none;
    }

    I have no Product Vendor plugin installation, so I am not sure about if vendor-admin is the proper role name.

    Let me know how it goes, or need any help.

Viewing 1 replies (of 1 total)
  • The topic ‘how can i hide by user role’ is closed to new replies.