Support » Plugin: WPAdverts - Classifieds Plugin » Require contact form logged in

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    I am trying this code snippet and it is working fine for me, additionally there wasn’t any changes in WPAdverts which would break it.

    lazyym

    (@lazyym)

    This is the code from that link.

    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";
    }

    I notice other functions have add_action, not just action like the code. When I replace it with add_action, it now works. 🙂

    The complete function that now works for me is

    add_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";
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Require contact form logged in’ is closed to new replies.