我的php经验有点超前了。请帮忙。
我正在尝试为联系人表单7创建一个自定义的快捷代码-使用插件"开发者烹饪书"
我想用短代码获取表单所在页面的url(permalink)然后在返回电子邮件的消息正文中使用此短代码,也就是说,向企业发送电子邮件通知-这样,企业就会知道此表单是从哪个登录页提交的,因为此表单将在许多登录页上使用。
以下是我迄今为止在functions.php文件中的代码:
add_action('wpcf7_init', 'custom_add_shortcode_lptitle');
function custom_add_shortcode_lptitle() {
wpcf7_add_shortcode('lptitle', 'custom_lptitle_shortcode_handler'); // "lptitle" is the type of the form-tag
}
function custom_lptitle_shortcode_handler($tag) {
global $post;
$url = get_permalink($post->ID);
return $url;
}
然后我在通知电子邮件的消息正文中使用的短代码是:登录页URL[lptitle]
在functions.php
中添加以下代码
wpcf7_add_shortcode('lptitle', 'custom_lptitle_shortcode_handler', true);
function custom_lptitle_shortcode_handler( $tag ) {
global $post;
$url = get_permalink($post->ID);
return $url;
}
你的短代码是
[lptitle]