简体   繁体   English

Buddypress - 将 HTML 添加到用户配置文件中 - 只有第一个配置文件组

[英]Buddypress - Add HTML into the User Profile - only first profile group

I've got 3 profile groups/sections in my Buddypress General profile tab.我的 Buddypress 常规个人资料选项卡中有 3 个个人资料组/部分。

I'm trying to add a custom shortcode into the first group, just under the first group.我正在尝试将自定义简码添加到第一组中,就在第一组下方。

This is my code:这是我的代码:

add_action( 'bp_after_profile_loop_content', 'profile_choices_display' );
function profile_choices_display() {
   if ( 1 == bp_get_the_profile_group_id()) { 
     echo do_shortcode( '[user-profile-choices]' );
   }      
}

Without the bp_get_the_profile_group_id() filter, the shortcode is repeated under each of the 3 groups on that page.如果没有bp_get_the_profile_group_id()过滤器,短代码将在该页面的 3 个组中的每一个下重复。

Any ideas how to achieve this so it only shows after the first group?任何想法如何实现这一点,所以它只在第一组之后显示?

The hook you used is called too late.您使用的钩子调用得太晚了。 Try:尝试:

add_action( 'bp_after_profile_field_content', 'profile_choices_display' );
function profile_choices_display() {
   if ( 'edit' !== bp_current_action() ) {
       if ( 1 == bp_get_the_profile_group_id()) { 
          echo do_shortcode( '[user-profile-choices]' );
       }
   }      
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM