2015-10-02 103 views
0

我想为cf7标记添加自定义字段。 (见图) 有没有我可以使用的add_filter钩子? 请帮帮我。添加自定义字段到联系人表单7标记

Thankk Example Image

+0

你能说说这个标签应该是什么吗?有一些标签没有很好的记录,如果没有 - 我知道一些方法,但它取决于自定义字段本身。 –

+0

您好Obmerk Kronen,并感谢您的回应。我想在每个标记中插入一个文本字段以将值传递给shortcode。谢谢 – Francesco

+0

是的,我了解 - 但价值是什么?就像上面说的那样,一些CF7标签已经存在了(虽然文档很差),并且不需要特殊的钩子,比如'sender IP','post_ID','sent_time','unique_id'以及其他很多其他的东西... –

回答

0

好,我可能误解你想要什么,但:

这是CF7如何注册文本字段shorttags:

add_action('wpcf7_init', 'wpcf7_add_shortcode_text'); 

function wpcf7_add_shortcode_text() { 
    wpcf7_add_shortcode(
     array('text', 'text*', 'email', 'email*', 'url', 'url*', 'tel', 'tel*'), 
     'wpcf7_text_shortcode_handler', true); 
} 

注意,钩wpcf7_init对于功能wpcf7_add_shortcode()所以,如果我们做我们自己的例子:

add_action('wpcf7_init', 'custom_add_shortcode_hello'); 



function custom_add_shortcode_hello() { 
    wpcf7_add_shortcode('helloworld', 'custom_hello_shortcode_handler'); // "helloworld" is the type of the form-tag 
} 

然后回调处理器

function custom_hello_shortcode_handler($tag) { 
    return 'hello world ! '; 
} 

现在如果你在表单中添加此

CF7 say : [helloworld] 

你应该看到

CF7 say : hello world ! 

如果你想使用标准型标签,请注意可用的默认类型为:

现在
text, text*, email, email*, tel, tel*, url, url*, textarea ,textarea* , number, number*, range and range* , date , date*,checkbox, checkbox*, radio, select and select* , file , file*, captchac ,captchar, quiz , acceptance, submit; 

,我写了这一切,因为据我所知(我可能是错的)存在对于一个已经存在的标记HTML表单的功能wpcf7_tg_pane_text_and_relatives()modules/text.php

中定义的任何过滤器

,但你可以做的是通过使用wpcf7_remove_shortcode($tag);删除默认标记(例如文本),然后通过创建一个新的(例如文本)添加自己的适应上述示例

这就是说,我并不确定你想要什么以及为什么这么做(你真的没有解释目标,只是方式),因为恕我直言,并且在很多CF7自定义插件之后我写道,我真的不明白为什么不创建一个更容易,更构建的新标签。

但是再次,我可能是错的。

+0

这不是我的问题的答案.. – Francesco

相关问题