How to show "add listing" button to specific users only?

Hello,

I started a topic asking how to show the “add listing” button only on certain pages. If that is not an option, I am trying to see if maybe it can be shown only to specific users, then direct certain users to that page.

I saw this topic:

User “yevhen” linked to an answer that tells you how to Add Listing Button Visible by Role but that link doesn’t show the article at all now so the solution does not work (I’ve already marked it for attention).

So I am wondering if there is a new article on this or if this can be achieved some other way.

Thank you

Hello, Maybe this works for you. This is how Im showing or hiding things depending on user role. Add this snippet to your functions.php

add_action( 'wp_head', function () {
    $user = wp_get_current_user();
    if ( ! in_array( 'contributor', (array) $user->roles ) ) return;
    ?>
    <style>

    .provendor {display: none !important;}

    </style>
    <?php
} );

In this example I am hiding a block to the role “contributor”, you can add whatever role you want,.

Then give your block or button a css class, in this example I gave the class “provendor”, you can name it what ever you want. This will hid this block from contributors.

Hello, thanks for the suggestion. If I can get it to work, I guess it would do in a pinch. But I don’t know the class name for the default Hivepress “Add listing” button, and I have more users I want to hide the button from than show it. Specifically. there is only one role that I would like to show this button to.

I could wait and see if the link in my first message gets updated - maybe that would work. In the meantime, this code might work but I don’t know the class ID for the button.

Hello, try this css to hide the button

.hp-menu--site-header .hp-menu__item--listing-submit {display: none !important;}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.