Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter kimharp

    (@kimharp)

    I wanted to follow up on this to say that I am currently using a membership plugin (PMPro) so if there is a way to wrap the contact form in a membership shortcode this could be a solution. Thoughts on whether that would work for me, and how?

    Thanks in advance….

    Plugin Author Greg Winiarski

    (@gwin)

    Hi, the only way to do that would be with some custom programming, for example the code below will hide the contact form from unregistered users

    
    action( "init", "my_contact_form_init", 1000 );
    function my_contact_form_init() {
        if( ! is_user_logged_in() ) {
            remove_all_actions( "adverts_tpl_single_bottom" );
        }
    }
    

    just replace is_user_logged_in() with your own condition to check if the user have required privileges, i am not familiar with PMPro plugin so you would need to ask their author about the code.

    Thread Starter kimharp

    (@kimharp)

    Hi Greg:

    Thanks! This works and we now have the form hidden just one more question: Is there a way to add text that would show only if they are not logged in?

    Thanks for your quick help!

    I would opt for an form option so the ad author can decide whether or not to allow the unregistered users to contact him using the contact form.

    Plugin Author Greg Winiarski

    (@gwin)

    Modify the code above to

    
    action( "init", "my_contact_form_init", 1000 );
    function my_contact_form_init() {
        if( ! is_user_logged_in() ) {
            remove_all_actions( "adverts_tpl_single_bottom" );
            add_action( "adverts_tpl_single_bottom", "anon_message" );
        }
    }
    function anon_message() {
        echo "Login to contact the seller";
    }
    
    Thread Starter kimharp

    (@kimharp)

    Thanks Greg, we’ve got it working now! Greatly appreciate your help and can’t wait to start using this plugin.

    Lurie, appreciate the feedback but that’s not an option for us. We have too many other parameters we’re dealing with.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Require Contact Form login?’ is closed to new replies.