WordPress.org

Support

Support » Plugins and Hacks » Contact Form 7 » [Resolved] [Plugin: Contact Form 7] Expire date contact form

[Resolved] [Plugin: Contact Form 7] Expire date contact form

  • I love the plug for several years but I bumped in to a small problem.
    What I like to do is give a expire date to the contact form and not to the complete post/page.

    What did I do:
    Added in the Functions template:

    add_shortcode('expire','expire_text');
      function expire_text($paras="",$content="") {
       extract(shortcode_atts(array('date'=>''),$paras));
       if ( ($date!="")&&(date("Ymd")>$date) ) {$content="";}
       return $content;
     }

    And in the post / page.
    [expire date=”20101201″] [contact-form 1 “Contact form 1”] [/expire]

    With this code the contact form is not visable
    But when I change the date in the future on the post/page I see
    [contact-form 1 “Contact form 1”] and not the form.

    Has anybody a idea how to fix it….

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Takayuki Miyoshi

    @takayukister

    You need do_shortcode() inside the expire_text(). See http://codex.wordpress.org/Shortcode_API#Enclosing_vs_self-closing_shortcodes

    Thanx for the tip Takayuki Miyoshi, the article solved my problem.

    add_shortcode('expire','expire_text');
    function expire_text($paras="",$content="") {
       extract(shortcode_atts(array('date'=>''),$paras));
       if ( ($date!="")&&(date("Ymd")>$date) ) {$content="";}
       return do_shortcode($content);
    }

    When other people like to use the code go to functions.php in your theme.
    Add the above code in it and when you make a post/page.
    For contact 7 form:
    [expire date=”20101201″] [contact-form 1 “Contact form 1”] [/expire]

    Or normal text:
    [expire date=”20101201″] test message [/expire]

    All the text or forms will be hidden after the expire date if it is between the [expite date=” “] [/expire].

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] [Plugin: Contact Form 7] Expire date contact form’ is closed to new replies.
Skip to toolbar