• Resolved viensia

    (@viensia)


    Hi Danny,

    Wonderful plugin!! Is there a way to have the box automatically close after someone submits a request on it? I am using contact 7 form and it would be great for it to close upon user input. Also, is there a code to keep it from opening again after input? Like the one that you have for mail-chimp?

    https://wordpress.org/plugins/scroll-triggered-boxes/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Danny van Kooten

    (@dvankooten)

    Hi there,

    Sure thing but it depends entirely on the thing you’re trying to integrate with. You can filter the box rules and keep the box hidden if a certain cookie is set so if you can set a cookie upon submitting a form, you’re good to go.

    Here is the example code for MailChimp for WordPress.

    // copy paste the following functions anywhere in your theme its functions.php file
    
    function my_prefix_set_mailchimp_cookie($email, $merge_vars, $form_id, $result) {
    	if($result == true) {
    		setcookie("mc4wp_subscribed", $email, time() + 31556926, '/');
    	}
    }
    
    add_action('mc4wp_after_subscribe', 'my_prefix_set_mailchimp_cookie', 10, 4);
    
    function my_prefix_show_stb_box($matched, $box_id) {
    
    	if(isset($_COOKIE['mc4wp_subscribed'])) {
    		return false;
    	}
    
    	return $matched;
    }
    
    add_action('stb_show_box', 'my_prefix_show_stb_box', 10, 2);

    I am thinking of adding a few integrations to the plugin to handle this kind of stuff automatically for some of the more popular plugins (like MailChimp for WordPress and Contact Form 7) so stay tuned. 🙂

    Plugin Author Danny van Kooten

    (@dvankooten)

    The above code can be simplified to the following snippet if you’re using MailChimp for WP version 1.5.4 or higher.

    function myprefix_show_stb_box( $matched, $box_id ) {
    
    	if( isset( $_COOKIE['mc4wp_email'] ) ) {
    		return false;
    	}
    
    	return $matched;
    }
    
    add_action('stb_show_box', 'myprefix_show_stb_box', 10, 2);
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide box after signup’ is closed to new replies.