[英](WordPress/UltimateMember) Hook functions not working in custom plugin / child theme
[英]Creating custom tab with ultimatemember plugin of wordpress
我一直在尝试为我的网站创建一个自定义选项卡,并且正在使用 UltimateMember 插件。
经过一番谷歌,我找到了一些可以帮助我做到的代码片段:
首先,我们需要扩展主配置文件选项卡
add_filter('um_profile_tabs', 'add_custom_profile_tab', 1000 );
function add_custom_profile_tab( $tabs ) {
$tabs['mycustomtab'] = array(
'name' => 'My custom tab',
'icon' => 'um-faicon-comments',
);
return $tabs;
}
然后我们只需使用此操作将内容添加到该选项卡
add_action('um_profile_content_mycustomtab_default', 'um_profile_content_mycustomtab_default');
function um_profile_content_mycustomtab_default( $args ) {
echo 'Hello world!';
}
但是我的问题是,我应该将这段代码添加到哪个文件来实现我的需要。 问这个问题我听起来很麻木,但我很困惑。
感谢您的帮助。
分享一下我的类似经历。 首先在这段代码中:
$tabs['mycustomtab'] = array(
'name' => 'My custom tab',
'icon' => 'um-faicon-comments',
);
你应该总是使用
我的自定义选项卡
作为我看到你已经使用过的钥匙。 所以这是真的。 通常,当您将此代码放在活动主题的functions.php 中时,它会起作用,但如果不起作用,请考虑将其添加到插件核心文件夹中的核心文件um-filters-misc.php 中,以供最终成员使用。 让我知道它是否适合你。
不确定是否有人仍然需要这方面的帮助,但请确保添加一个“自定义”键/值,如下所示:
$tabs['mycustomtab'] = array(
'name' => 'My custom tab',
'icon' => 'um-faicon-comments',
'custom' => true // <- needs to be added so it shows up on the profile page
);
UltimateMember 文档中的代码示例(专门用于使用钩子扩展配置文件菜单)不起作用,因为示例代码没有该行。
大家好,感谢您的帮助...我正在使用此代码并且工作“很好”...如果要放置拍摄代码,网站会打印“蓝屏”错误... [ultimatemember form_id="15817"](如果我使用“你好词”工作完美..
function um_mycustomtab_add_tab( $tabs ) {
$tabs['mycustomtab'] = array(
'name' => 'Seguimiento',
'icon' => 'um-faicon-pencil',
);
return $tabs;
}
add_filter( 'um_profile_tabs', 'um_mycustomtab_add_tab', 1000 );
// Action
function um_profile_content_mycustomtab_default( $args ) {
echo do_shortcode('[ultimatemember form_id="15817"]'); //this not work
}
add_action( 'um_profile_content_mycustomtab_default', 'um_profile_content_mycustomtab_default');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.