Disable contact button based on current user logged in status

I would like to be able to disable the 'contact me' button on an experts profile page if the current user is not logged in. OR can the popup window that prompts the user to register or login once this button is clicked, be re-directed to another login/register page that i have? I don't want to have to manage two login/registration pages.

  • Predrag Dubajic

    Hey @Brooke,

    Hope you're doing well today :slight_smile:

    Simplest way to deal with this is to use this CSS code that will hide contact button for logged out users:

    .expert-avatar .panel-footer {
    	display: none;
    }
    
    .logged-in .expert-avatar .panel-footer {
    	display: block;
    }

    If your theme doesn't have custom CSS field, then you may wish to use a child theme or a plugin like this one for this additional CSS. That way you're protected when you come to upgrade.

    Best regards,
    Predrag

  • Brooke

    Hi I've retested it this morning and I don't think it is your code. It looks fine some times and then others the experts are gone.. I've just deactivated the plugin that I thought was causing the problem and it is working completely fine now. thankfully its only a plugin i use when i'm maintaining my site (so my coming soon page).. Many thanks for that one..

    Can i ask that the same be done on the job single page? at the moment when a user is not logged in and they are viewing a job, the contact button is active but prompts the user to log in.

  • Predrag Dubajic

    Hi Brooke,

    Can i ask that the same be done on the job single page? at the moment when a user is not logged in and they are viewing a job, the contact button is active but prompts the user to log in.

    Try with this CSS please:

    .row.hn-border.hn-border-round.jobs-meta {
        border-right: none;
    }
    
    .jbp-job-single .jobs-meta .col-md-3 {
    	width: 33.33%;
    }
    
    .jbp-job-single .jobs-meta div.jobs-meta-row:nth-child(4) {
        display: none;
    }

    I have created a link in my faq to the 'add an expert' page. When someone is logged out this link is active but re-directs them to the jobs and experts login/register page. Can i change this default login/register page to my woocommerce one?

    I'm not sure I understand what exatcly is going on here, could you grant support access to your site and provide a link to page in question so we can check this out?

    To enable support access you can follow this guide here:
    https://premium.wpmudev.org/manuals/wpmu-dev-dashboard-enabling-staff-login/

    If you have not installed WPMU DEV Dashboard plugin yet, kindly do that here : https://premium.wpmudev.org/project/wpmu-dev-dashboard/ and then allow access as per the above process.

    Best regards,
    Predrag

  • Brooke

    So i've created a text link to the 'add-an-expert' form as per screenshot 1. This link when clicked on my a user that is not currently logged in redirects them to to login or register page as per screen shot 3. This page I presume is the jobs and experts login/register page? But i have another login /register page that i would prefer to use (screen shot 2). Is there anyway i can redirect which login page logged out users are taken to?

  • Brooke

    Oh and the code you gave me to disable the contact button on the jobs single page removes the button completely even for logged in users. I would like logged in users to be able to contact the person who listed the job via this contact button, but i would like to either disable the button for logged out users.. or redirect the login/register link that is activated when a logged out user clicks on this button to my desired registration page (as per my screenshots above). Thanks.

  • Predrag Dubajic

    Hi Brooke,

    Ah yes, I forgot it should show for logged in users, sorry about that, here's the modified code to hide the button only for logged out users:

    .row.hn-border.hn-border-round.jobs-meta {
        border-right: none;
    }
    
    .jbp-job-single .jobs-meta .col-md-3 {
    	width: 33.33%;
    }
    
    .jbp-job-single .jobs-meta div.jobs-meta-row:nth-child(4) {
        display: none;
    }
    
    .logged-in .row.hn-border.hn-border-round.jobs-meta {
        border-right: solid 1px #ddd;
    }
    
    .logged-in .jbp-job-single .jobs-meta .col-md-3 {
    	width: 25%;
    }
    
    .logged-in .jbp-job-single .jobs-meta div.jobs-meta-row:nth-child(4) {
        display: block;
    }

    About the registration page, if the link is custom created why don't you just link it to your desired registration page?
    If the reason is that you wont be redirected to job creation page after login than you can use any login redirect plugin which you can set to go to create job page after login.

    Let me know if I'm missing something :slight_smile:

    Best regards,
    Predrag

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.