使用wordpress的最终成员插件创建自定义选项卡


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',
 );

您应该始终使用

mycustomtab

我看你已经用过了。所以这是真的。一般来说,当你把这些代码放在活动主题的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文档中的代码示例(专门用于使用钩子扩展配置文件菜单)不起作用,因为示例代码没有这一行。

大家好,谢谢你们的帮助。。。我使用这些代码,效果"很好"。。。如果一个想放shotcode网站打印"蓝屏"错误。。。[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');

这里有一些测试的屏幕截图