Contact Form 7 Custom module

时间:2011-08-21 作者:Ashfame

我正在使用自定义帖子类型名称venue 我用的是<select> 通过在CF7中加载自定义模块,在其中一个联系人表单上下拉列表,但在提交表单时,我的数据快捷码不会替换为用户填写的数据。

我刚看到这个[selected-venue]. 以下是我的自定义模块代码:

<?php

wpcf7_add_shortcode( \'party-venue\', \'wpcf7_venue_shortcode_handler\', true );

function wpcf7_venue_shortcode_handler( $tag ) {

    global $wpdb;

    $query = "SELECT post_title FROM {$wpdb->posts} where post_type = \'venue\' and post_status = \'publish\';";

    $result = $wpdb->get_col( $query );

    if ( $result ) {
        $output = \'<select name="contact_venue" id="contact_venue" class="input-select">\';
        $output.= \'<option></option>\';
        foreach ( $result as $venue ) {
            $output.= \'<option value="\'.$venue.\'">\'.$venue.\'</option>\';
        }
        $output.= \'</select>\';
    }

    return $output;
}
我的联系方式代码是

<label for="contact_name"><span class="large_contact">name</span><span class="small_contact">Please enter your full name</span></label>[text* your-name class:input-textarea] 
<label for="contact_email"><span class="large_contact">email</span><span class="small_contact">Please enter a valid email address</span></label>[email* your-email class:input-textarea]
<label for="contact_phone"><span class="large_contact">phone</span><span class="small_contact">Please enter a phone number to reach you at</span></label>[text phone class:input-textarea]
<label for="contact_friends"><span class="large_contact">party size</span><span class="small_contact">*Min 50 guests for free bottle, 15 guests for buy 1 bottle get 1 free*</span></label>[text party-size class:input-textarea] </p>
<label for="contact_venue"><span class="large_contact">venue</span><span class="small_contact">Please select your party venue</span></label>[party-venue selected-venue id:contact_venue]
<label for="contact_date"><span class="large_contact">date</span><span class="small_contact">Please enter your party date (mm/dd/yy)</span></label>[text date id:contact_date class:input-textarea]
<label for="referal_source"><span class="large_contact">How did you hear about us?</span><span class="small_contact">Please select one of the options</span></label>[select menu-367 class:input-select "" "CitySearch" "Facebook" "Facebook Ad" "Friend" "Google Search" "NYC Daily Deals" "Yelp"]

[submit class:input-submit]
这是我的信息正文:

From: [your-name] <[your-email]>
Subject: Book a party!

Message Body:
Phone: [phone], 
Party Size: [party-size], 
Venue: [selected-venue], 
Date: [date]
How did you hear about us: [menu-367]
当我收到提交表格的电子邮件时,[selected-venue] 不会替换为“选择”下拉列表的实际值。我做错了什么?

1 个回复
最合适的回答,由SO网友:Ashfame 整理而成

输入字段的名称应与填充符短代码匹配,以便它返回数据。我改变了$output = \'<select name="contact_venue"$output = \'<select name="selected-venue" 现在它可以工作了。

结束

相关推荐

Contact Form 7 Custom module - 小码农CODE - 行之有效找到问题解决它

Contact Form 7 Custom module

时间:2011-08-21 作者:Ashfame

我正在使用自定义帖子类型名称venue 我用的是<select> 通过在CF7中加载自定义模块,在其中一个联系人表单上下拉列表,但在提交表单时,我的数据快捷码不会替换为用户填写的数据。

我刚看到这个[selected-venue]. 以下是我的自定义模块代码:

<?php

wpcf7_add_shortcode( \'party-venue\', \'wpcf7_venue_shortcode_handler\', true );

function wpcf7_venue_shortcode_handler( $tag ) {

    global $wpdb;

    $query = "SELECT post_title FROM {$wpdb->posts} where post_type = \'venue\' and post_status = \'publish\';";

    $result = $wpdb->get_col( $query );

    if ( $result ) {
        $output = \'<select name="contact_venue" id="contact_venue" class="input-select">\';
        $output.= \'<option></option>\';
        foreach ( $result as $venue ) {
            $output.= \'<option value="\'.$venue.\'">\'.$venue.\'</option>\';
        }
        $output.= \'</select>\';
    }

    return $output;
}
我的联系方式代码是

<label for="contact_name"><span class="large_contact">name</span><span class="small_contact">Please enter your full name</span></label>[text* your-name class:input-textarea] 
<label for="contact_email"><span class="large_contact">email</span><span class="small_contact">Please enter a valid email address</span></label>[email* your-email class:input-textarea]
<label for="contact_phone"><span class="large_contact">phone</span><span class="small_contact">Please enter a phone number to reach you at</span></label>[text phone class:input-textarea]
<label for="contact_friends"><span class="large_contact">party size</span><span class="small_contact">*Min 50 guests for free bottle, 15 guests for buy 1 bottle get 1 free*</span></label>[text party-size class:input-textarea] </p>
<label for="contact_venue"><span class="large_contact">venue</span><span class="small_contact">Please select your party venue</span></label>[party-venue selected-venue id:contact_venue]
<label for="contact_date"><span class="large_contact">date</span><span class="small_contact">Please enter your party date (mm/dd/yy)</span></label>[text date id:contact_date class:input-textarea]
<label for="referal_source"><span class="large_contact">How did you hear about us?</span><span class="small_contact">Please select one of the options</span></label>[select menu-367 class:input-select "" "CitySearch" "Facebook" "Facebook Ad" "Friend" "Google Search" "NYC Daily Deals" "Yelp"]

[submit class:input-submit]
这是我的信息正文:

From: [your-name] <[your-email]>
Subject: Book a party!

Message Body:
Phone: [phone], 
Party Size: [party-size], 
Venue: [selected-venue], 
Date: [date]
How did you hear about us: [menu-367]
当我收到提交表格的电子邮件时,[selected-venue] 不会替换为“选择”下拉列表的实际值。我做错了什么?

1 个回复
最合适的回答,由SO网友:Ashfame 整理而成

输入字段的名称应与填充符短代码匹配,以便它返回数据。我改变了$output = \'<select name="contact_venue"$output = \'<select name="selected-venue" 现在它可以工作了。

相关推荐

Contact Form 7 Custom module - 小码农CODE - 行之有效找到问题解决它

Contact Form 7 Custom module

时间:2011-08-21 作者:Ashfame

我正在使用自定义帖子类型名称venue 我用的是<select> 通过在CF7中加载自定义模块,在其中一个联系人表单上下拉列表,但在提交表单时,我的数据快捷码不会替换为用户填写的数据。

我刚看到这个[selected-venue]. 以下是我的自定义模块代码:

<?php

wpcf7_add_shortcode( \'party-venue\', \'wpcf7_venue_shortcode_handler\', true );

function wpcf7_venue_shortcode_handler( $tag ) {

    global $wpdb;

    $query = "SELECT post_title FROM {$wpdb->posts} where post_type = \'venue\' and post_status = \'publish\';";

    $result = $wpdb->get_col( $query );

    if ( $result ) {
        $output = \'<select name="contact_venue" id="contact_venue" class="input-select">\';
        $output.= \'<option></option>\';
        foreach ( $result as $venue ) {
            $output.= \'<option value="\'.$venue.\'">\'.$venue.\'</option>\';
        }
        $output.= \'</select>\';
    }

    return $output;
}
我的联系方式代码是

<label for="contact_name"><span class="large_contact">name</span><span class="small_contact">Please enter your full name</span></label>[text* your-name class:input-textarea] 
<label for="contact_email"><span class="large_contact">email</span><span class="small_contact">Please enter a valid email address</span></label>[email* your-email class:input-textarea]
<label for="contact_phone"><span class="large_contact">phone</span><span class="small_contact">Please enter a phone number to reach you at</span></label>[text phone class:input-textarea]
<label for="contact_friends"><span class="large_contact">party size</span><span class="small_contact">*Min 50 guests for free bottle, 15 guests for buy 1 bottle get 1 free*</span></label>[text party-size class:input-textarea] </p>
<label for="contact_venue"><span class="large_contact">venue</span><span class="small_contact">Please select your party venue</span></label>[party-venue selected-venue id:contact_venue]
<label for="contact_date"><span class="large_contact">date</span><span class="small_contact">Please enter your party date (mm/dd/yy)</span></label>[text date id:contact_date class:input-textarea]
<label for="referal_source"><span class="large_contact">How did you hear about us?</span><span class="small_contact">Please select one of the options</span></label>[select menu-367 class:input-select "" "CitySearch" "Facebook" "Facebook Ad" "Friend" "Google Search" "NYC Daily Deals" "Yelp"]

[submit class:input-submit]
这是我的信息正文:

From: [your-name] <[your-email]>
Subject: Book a party!

Message Body:
Phone: [phone], 
Party Size: [party-size], 
Venue: [selected-venue], 
Date: [date]
How did you hear about us: [menu-367]
当我收到提交表格的电子邮件时,[selected-venue] 不会替换为“选择”下拉列表的实际值。我做错了什么?

1 个回复
最合适的回答,由SO网友:Ashfame 整理而成

输入字段的名称应与填充符短代码匹配,以便它返回数据。我改变了$output = \'<select name="contact_venue"$output = \'<select name="selected-venue" 现在它可以工作了。

相关推荐