Hi there, I’m using the following code to show Xprofile Field Data in The Profile Header.
I want the code excluded from profiles own profile. The only way I know is to exclude the code from being displayed with css .myaccount But it’s not wrapped in a div so I have no class to attack. What is best, adding a div class, or exclude own profile in the code?
Help with both solutions would be much appreciated, thanks!
/** * Buddypress Show Xprofile Field Data in The Profile Header. */ function yzc_add_xprofile_field_data_in_profile_header( $name ) { $field_data = xprofile_get_field_data( 'Age', bp_displayed_user_id() ); if ( ! empty( $field_data ) ) { echo '<br/><strong>Alder:</strong> ' . $field_data; $field_data = xprofile_get_field_data( 'From', bp_displayed_user_id() ); if ( ! empty( $field_data ) ) { echo ' <br/> <strong>Fra:</strong> ' . $field_data; $field_data = xprofile_get_field_data( 'Job', bp_displayed_user_id() ); if ( ! empty( $field_data ) ) { echo '<br/><strong>Job:</strong> ' . $field_data; } } } } add_action( 'bp_before_member_header_meta', 'yzc_add_xprofile_field_data_in_profile_header' );
Hi Carsten,
Thank you for the question.You can use it like this.
/** * Buddypress Show Xprofile Field Data in The Profile Header. */ function yzc_add_xprofile_field_data_in_profile_header( $name ) { if ( bp_is_my_profile() ) { return; } $field_data = xprofile_get_field_data( 'Age', bp_displayed_user_id() ); if ( ! empty( $field_data ) ) { echo '<br/><strong>Alder:</strong> ' . $field_data; $field_data = xprofile_get_field_data( 'From', bp_displayed_user_id() ); if ( ! empty( $field_data ) ) { echo ' <br/> <strong>Fra:</strong> ' . $field_data; $field_data = xprofile_get_field_data( 'Job', bp_displayed_user_id() ); if ( ! empty( $field_data ) ) { echo '<br/><strong>Job:</strong> ' . $field_data; } } } } add_action( 'bp_before_member_header_meta', 'yzc_add_xprofile_field_data_in_profile_header' );
Regards
BrajeshYou are welcome. No issues with duplicate topic.
Regards
Brajesh
Viewing 5 posts - 1 through 5 (of 5 total)
The topic ‘show Xprofile Field Data in The Profile Header, exclude own profile’ is closed to new replies.
This topic is: not resolved