[英]Buddypress - Add HTML into the User Profile - only first profile group
我的 Buddypress 常规个人资料选项卡中有 3 个个人资料组/部分。
我正在尝试将自定义简码添加到第一组中,就在第一组下方。
这是我的代码:
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]' );
}
}
如果没有bp_get_the_profile_group_id()
过滤器,短代码将在该页面的 3 个组中的每一个下重复。
任何想法如何实现这一点,所以它只在第一组之后显示?
您使用的钩子调用得太晚了。 尝试:
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.