Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: bp_field_has_data show message when empty field

@jimmmy

Participant

@danbp Thank you man, this is amazing!

It didn’t do exactly what i wanted, so i made a couple of tweaks. I changed the filter so the messages were added to the profile only, not the member header meta. I also made the statement into elseif, with an array, so it would do what i needed it to, ie show up only if both fields were empty. Here’s my code. It is probably a bit messy, but it does the trick:

function bpfr_my_message_on_profile () {	
	
        if ( bp_is_my_profile()) :
	
	if ( !$data = bp_get_profile_field_data( 'field=About' ) ) : 
	
	echo '<p class="enter-info">Please tell the community a little bit about yourself by filling out the form on the edit tab above.</p>';	
	
	elseif ( !$data = bp_get_profile_field_data(array( field=>'vimeo',field=>'youtube') ) ) : 
	
	echo '<p class="enter-info">There is nothing here! Spruce up your profile by adding content via the edit tab above.</p>';
	endif;
	endif;
}
add_filter( 'bp_before_profile_content', 'bpfr_my_message_on_profile' );

Thanks for all your help. You rock!

Skip to toolbar