function my_bp_nav_adder()
{
bp_core_new_nav_item(
array(
\'name\' => __(\'information\', \'buddypress\'),
\'slug\' => \'info\',
\'position\' => 15,
\'show_for_displayed_user\' => true,
\'screen_function\' => \'all_conversations_link\',
\'default_subnav_slug\' => \'testing\',
\'item_css_id\' => \'all-conversations\'
));
}
// Load a page template for your custom item. You\'ll need to have an item-one- template.php and item-two-template.php in your theme root.
function all_conversations_link () {
}
add_action( \'bp_setup_nav\', \'my_bp_nav_adder\' );
我试图在我刚刚创建的名为“信息”的选项卡中显示一些自定义字段的值。我已经创建了名为location的自定义配置文件字段。使用此代码获取值
<?php
//code inside the directory loop
$location= xprofile_get_field_data( "Contact Person" ,bp_get_member_user_id());//fetch the text for location
echo " $location ";
?>
然而,我认为这是一个破碎的页面。我确实得到了输出,但它显示在页面顶部。如何正确设置这些值的格式,使其符合线条和剖面
最合适的回答,由SO网友:Boone Gorges 整理而成
问题是您没有指定BuddyPress应该使用哪个模板来显示您的内容。有几种方法可以做到这一点(请参见https://github.com/boonebgorges/buddypress-skeleton-component/blob/master/includes/bp-example-screens.php 但我建议如下
// This is the screen_function called in bp_core_new_nav_item()
function all_conversations_link() {
add_action( \'bp_template_content\', \'all_conversations_content\' );
bp_core_load_template( \'members/single/plugins\' );
}
// This is the function that actually contains your content
function all_conversations_content() {
$location= xprofile_get_field_data( "Contact Person" , bp_get_member_user_id());//fetch the text for location
echo " $location ";
}