How to make the "add listing" button appear only on one specific page and show the price packages instead of asking user to log in?

Hello

I am using the ListingHive theme and I have several pages for my site, some are from other plugins. On every page, the green button for adding a listing is there but it does not always make sense to have them there. For example it is even on the vendor profile page, and it is also there when the user is logged out.

I would like to have a dedicated page for adding listings (I will make a menu button to add a listing that takes people to a page to make the listing) rather than have the button displayed on every page. Or, at least, have just one page show the green add listing button, such as in the person’s profile page for certain user roles only. I would also like, if the user is logged out, to not have the button display at all. If the user is logged in (ie they created an account but haven’t yet bought a package), I would like to have either a page from a menu button, or a page led to by clicking on the green add listing button, that shows them the price for the listings first, rather than have them fill out the form, press the submit button, then find out they ave to pay. Right now logged in users can click the button to add a listing, spend time filling out the information then find out they have to pay and the prices for the listings afterwards.

Thank you

Hi!
First: to hide the “Add Listing” button if the user not logged in, you can use this css:

body:not(.logged-in) .hp-menu--site-header .hp-menu__item--listing-submit{
  display: none;
}

or this php snippet:

/* Hide add listing button from non logged in
---------------------------------------------
*/

if (! is_user_logged_in() ) { 
   echo '<style>
      .hp-menu__item--listing-submit {
         display: none !important;
   </style>';
}

Second: If you want to inform your users, they need to buy a premium package for submit a listing, the fastest (but not so professional) solution is that, display a message on the submit listing page:

.hp-form--listing-submit:before{content:'Attention! To publish listings on our website, you need to purchase a premium package. Find out about the prices and contents of the packages in the "About Packages" menu'; color: white; display: block; background-color: red; padding: 5px;}

Create a new page in the WordPress dashboard->Pages->New, and add the title “About Packages” or what you want. You need to place here a block, where you show the premium packages for your users. Text, images or whatever, or just add the Woocommerce “All products” block, to display your packages. Publish this page, and after, go WP dasboard->Appearance->Menus. Select Header menu, and add the newly created page on the left side, to the menu. This will add a new button “About Packages”.

1 Like

Hi Fabricator,
Thank you for your reply!
First of all, I can confirm that the CSS to hide the “Add listing” button works, but the PHP does not (I tested them separately and used the Code Snippet plugin).

One thing I want to add is, I noticed that even before I used the CSS, the “add listing” button does not appear in mobile device views either on a mobile device or in “inspect” mode on a desktop browser. This means users who want to add a listing on a mobile device, can’t even see the button.

Second: Regarding your suggested solution about adding a notice to user about the packages before submitting a listing: I agree that this is not very professional. However, it is also not what i am entirely after. Ideally, the option to add a listing should only appear on one page and accessed via a menu button. I don’t want it appearing on every page. This is because for a job site, only employers should be able to post jobs, not applicants, but right now, applicants who log in can also see the “add listing” button.

I am differentiating the roles of job posters and job seekers by giving them separate registration forms using a third party plugin, and upon registration, they are given a user role of either “job seeker” or “job poster”.

Even for job posters, it does not look good when they log in and the “add listing” button is on every page. For job posters, I would like there to be a dedicated page where they can add a listing, accessed by a button in the menu. I am able to add a new page and create a menu button for it, that is no problem. What I can’t do is, remove the “Add listing” function for logged in users of a specific role (everyone besides job posters), and remove the button from displaying on every page for job posters and create a menu button instead. If I can just make the “Add listing” functionality appear on a single page, I can create a page and make a menu button myself, then give access to that page only to people who sign up as job posters.

I hope that makes sense.

Hello Fabricator,

Thank you for your help and suggestion. I unchecked your solution because it works only in the case if I want to show a warning before the user posts a listing that they have to pay, but it doesn’t solve the case if I want to display the add listing button only on certain pages. This is important for me because I will be restricting certain pages according to user roles.

I would like to reopen this topic in case there is a solution for it.
Thanks