Reply To: bp_field_has_data show message when empty field
hi @jimmmy
Give this a try. Copy/paste into your theme’s functions.php or into bp-custom.php
- – The code will only apply on the members profile page.
- – Add if /endif for each field you need
- – The message will appear under the username. Do get this on the bp-default theme, The first echo containing BR is probably mandatory.
- – The field name is case sensitive.
function bpfr_my_message_on_profile () {
echo '<br>Test my message<br>';
if ( !$data = bp_get_profile_field_data( 'field=your_field_name_1' ) ) :
echo xprofile_get_field_data( 'your_field_name', bp_displayed_user_id() ) .'The message to display 1<br>';
endif;
if ( !$data = bp_get_profile_field_data( 'field=your_filed_name_2' ) ) :
echo xprofile_get_field_data( 'your_field_name_2', bp_displayed_user_id() ) .'The message to display 2<br>';
endif;
}
add_filter( 'bp_before_member_header_meta', 'bpfr_my_message_on_profile' );