-
Author
-
November 11, 2016 at 07:14 #143864
yumnihon
ParticipantI have a example as bellow:
I logged in site with my profile have sex am men.
How code to i only can see other profile have sex is women, and only can Add Friend, send messenger,… if they is women.
November 14, 2016 at 06:48 #144086Laura
ModeratorHello, check https://archived.seventhqueen.com/forums/topic/restrict-looking-for-the-opposite
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionNovember 14, 2016 at 11:43 #144134yumnihon
ParticipantHi Laura
My I am fiel ID is 307 (group_id=1&field_id=307)
I insert bellow code, but it didnot work.COPY CODEclass BP_Custom_User_Ids { private $custom_ids = array(); public function __construct() { $this->custom_ids = $this->get_custom_ids(); add_action( 'bp_pre_user_query_construct', array( $this, 'custom_members_query' ), 1, 1 ); add_filter( 'bp_get_total_member_count', array( $this, 'custom_members_count' ), 1, 1 ); } private function get_custom_ids() { global $wpdb; //figure out if the logged-in user is male or female $sex = xprofile_get_field_data( 307, bp_loggedin_user_id() ); if ( $sex == 'Man' ) $query = "SELECT user_id FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 307 AND value = 'Woman'"; else $query = "SELECT user_id FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 307 AND value = 'Man'"; $custom_ids = $wpdb->get_col( $query ); return $custom_ids; } function custom_members_query( $query_array ) { $query_array->query_vars['include'] = $this->custom_ids; } function custom_members_count ( $count ) { $new_count = count( $this->custom_ids ); return $new_count; } } function custom_user_ids( ) { new BP_Custom_User_Ids (); } add_action( 'bp_before_directory_members', 'custom_user_ids' );November 15, 2016 at 19:43 #144326Laura
ModeratorHello, that code is still too old, you might need the help of a developer to fix it, if it does not work it must be incompatible
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.