Display something different to male and female members based off xprofile values
-
Hi,
I’m trying to display something different to male and female members on my site based off their selected xprofile value (created a gender field with male and female values) but can’t figure it out. I pieced the below code together after Googling around for awhile. I thought it would work but it simply echos ‘male’ twice on the page instead of echoing ‘male’ to male members and ‘female’ to female members. There probably is a more efficient way to achieve this and I’m not even sure I’m on the right track. Any ideas? Much appreciated!
<?php global $wpdb; $custom_value_male = $wpdb->get_col("SELECT user_id FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 2 AND value = 'Male'"); $custom_value_female = $wpdb->get_col("SELECT user_id FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 2 AND value = 'Female'"); if( $custom_value_male ) { echo 'male'; } else if( $custom_value_female ) { echo 'female'; } else { null; } ?>
Best Regards,
Mark
- The topic ‘Display something different to male and female members based off xprofile values’ is closed to new replies.