【问题标题】:Creating custom tab with ultimatemember plugin of wordpress使用 wordpress 的 Ultimatemember 插件创建自定义选项卡
【发布时间】:2016-04-05 12:21:17
【问题描述】:

我一直在尝试为我的网站创建一个自定义标签,并且正在使用 UltimateMember 插件。

经过一番谷歌,我找到了一些代码 sn-p 可以帮助我做到这一点:

首先我们需要扩展主配置文件标签

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!';
}

但我的问题是,我应该将此代码添加到哪个文件中才能实现我的需要。问这个听起来我很麻木,但我很困惑。

感谢您的帮助。

【问题讨论】:

  • 到您的functions.php 文件?
  • @dingo_d 已经尝试过了。不起作用。 :(

标签: php tabs wordpress


【解决方案1】:

让我分享一下我的类似经历。首先在这段代码中:

$tabs['mycustomtab'] = array(
  'name' => 'My custom tab',
  'icon' => 'um-faicon-comments',
 );

你应该总是使用

我的自定义标签

作为我看到你已经使用过的键。所以这是真的。 通常,当您将此代码放入活动主题的 functions.php 时,它会起作用 但如果它不起作用,请考虑将其添加到最终成员的插件核心文件夹中的核心文件 um-filters-misc.php 中。让我知道它是否适合你。

【讨论】:

  • 为我工作。必须将其添加到 um-filters-misc.php 文件中。谢谢。你拯救了我的一天。
【解决方案2】:

不确定是否还有人需要这方面的帮助,但请确保添加一个“自定义”键/值,如下所示:

$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 documentation 中的代码示例 - 专门用于使用钩子扩展配置文件菜单 - 不起作用,因为示例代码没有该行。

【讨论】:

    【解决方案3】:

    大家好,感谢您的帮助...我正在使用此代码并且工作“很好”...如果想将拍摄代码放入网站打印“蓝屏”错误...[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');
    

    here some screenshots tests

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-01
      • 1970-01-01
      相关资源
      最近更新 更多