Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
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' ); 

I am trying to display some value of custom fields in the tab that I have just created called information. I have created custom profile fields called location. using this code I am fetching the value

<?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 ";

?>

However I get this to be a broken page.I do get the output but it is displayed at the top of the page.How to correctly format these values to fit in line and diplay like the profile

share|improve this question

1 Answer 1

up vote 0 down vote accepted

The problem is that you're not specifying which template BuddyPress should use to display your content. There are a couple of ways to do it (see https://github.com/boonebgorges/buddypress-skeleton-component/blob/master/includes/bp-example-screens.php for a few options), but I suggest the following

// 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 ";
}    
share|improve this answer
    
Thanks. Solved . I hope I accepted your answer and thats all that needs to be done –  Sam Apr 14 '12 at 8:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.