Skip to:
Content
Pages
Categories
Search
Top
Bottom

Show or Hide Field Based on Match in Another Field

  • @a3132

    Participant

    Okay, I have learned to use code to show profile fields on different parts of the page. But I was wondering if it were possible to show or hide one field based on whether the profile member and the member viewing the profile were a match in another field.

    For example, could I:

    show the field favorite color if a man is viewing a woman’s profile or a woman is viewing a man’s profile – but – hide the field favorite color if a man is viewing a man’s profile or a woman is viewing a woman’s profile?

    By the way, thanks for the support forum. It’s been a lot of help.

Viewing 1 replies (of 1 total)
  • @clickallco

    Participant

    Should be pretty easy with something like this. This would only work if they’re logged in and have chosen to fill out the field on whether or not their a man or a woman though.

    <?php 
        	global $bp;
        	$user_id = bp_displayed_user_id();
        	$details = xprofile_get_field_data( 'profile field name', $user_id, $multi_format = 'array' );
    		
    	if ( ! empty ( $details) ) {	
    	  // if the field isn't empty, show this code
            } else {		
    	  //code
    	} 
    ?>
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar