WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
[resolved] Expire date contact form (3 posts)

  1. weedam
    Member
    Posted 3 years ago #

    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....

  2. Takayuki Miyoshi
    Member
    Plugin Author

    Posted 3 years ago #

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

  3. weedam
    Member
    Posted 3 years ago #

    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].

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic