-
Author
Tagged: pagination in member page
-
December 9, 2014 at 13:41 #38288LauraModerator
Hello, many of you wanted to restrict some member fields from finding their same sex/field, so this code will do it, you only need to make a simple changes and it will do the work.
First, find out what is the field id you want to use, like Gender/Sex so if i choose Female, i can only find Male.
1. Find field ID (Attachment 1)
2. Change the number 38 in the code for your field ID
3. Change the Names in the code for your field names (Male/Female)
4. IMPORTANT! Dont change nothing more.
5. IMPORTANT! Profile fields id NEVER starts with a 0
6. Code in functions.php of child theme
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( 852, bp_loggedin_user_id() ); if ( $sex == 'Male' ) $query = "SELECT user_id FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 38 AND value = 'Female'"; else $query = "SELECT user_id FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 38 AND value = 'Male'"; $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' );
Laura Solanes - Graphic Designer and Web Designer
Please be patient as I try to answer each topic as fast as i can.
If you like the theme or the support you've received please consider leaving us a review on Themeforest!
Always happy to help you 🙂
Attachments:
You must be logged in to view attached files.December 30, 2014 at 16:18 #40710LauraModeratorHello, add this to your functions.php in child theme
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionLaura Solanes - Graphic Designer and Web Designer
Please be patient as I try to answer each topic as fast as i can.
If you like the theme or the support you've received please consider leaving us a review on Themeforest!
Always happy to help you 🙂
January 1, 2015 at 12:07 #40834LauraModeratorHello, will work on a solution for you, but for Arrowchat you would need to contact their support.
2.You should contact a developer to do this for you as it requires extra custom work.
3.Check out this post https://archived.seventhqueen.com/forums/topic/membership-auto-in-registration#post-5411
To disable changing gender after registration use this code:COPY CODEfunction disable_name_change( $data ) { if ( 852 == $data->field_id ) $data->field_id = false; return $data; } add_action( 'xprofile_data_before_save', 'disable_name_change' );
IMPORTANT – Change 852 for the “I am a” Field ID (located in the url when you edit the field)
If they try to change gender and save, it will show an error message.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionLaura Solanes - Graphic Designer and Web Designer
Please be patient as I try to answer each topic as fast as i can.
If you like the theme or the support you've received please consider leaving us a review on Themeforest!
Always happy to help you 🙂
January 12, 2015 at 13:24 #41737tdateParticipantIt working good for once load members page.
http://rateurdates.com/members
But when i click on page number in pagination then it’s can’t work properly.
In next page it will shows all member (Means male and female both).
So can you help me how to fixed this problem.
Page No1:
Page No2:
January 16, 2015 at 00:18 #42272AbeKeymasterHi, right now the code could have some problems and we will try to fix them and once we do that we will include it in the theme.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution---
@ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.January 16, 2015 at 09:22 #42320tdateParticipantCan you please tell me when you will fixed it?
I want to fixed this issue ASAP in my current theme code.
Because it’s urgent for me.January 17, 2015 at 02:32 #42439AbeKeymasterThis is just a custom code given here from a user contribution and not in the theme as a feature. Can’t really say when we will update this code. Will keep you posted
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution---
@ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.August 11, 2015 at 20:36 #72602iamj_kimParticipantI have this same issue when viewing other pages. The Gender always comes back. Can it be revisited and fixed? Thanks.
September 18, 2015 at 11:05 #78333AbeKeymasterHi, are you using the latest theme version since it should be fixed?
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution---
@ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.December 28, 2015 at 08:33 #95392gugga7ParticipantThis is useless unfortunately. If you change any search criteria, it will go back to showing both genders…
December 28, 2015 at 19:12 #95457AbeKeymasterCan you check it on the demo since I can’t reproduce it?
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution---
@ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.December 29, 2015 at 13:24 #95549gugga7ParticipantMay be I misunderstood but this restriction and code is not installed on your demo so I can’t test it there.
January 9, 2016 at 17:16 #97507AbeKeymasterSorry for that, you are right and that solution is just a workaround and not a fully tested one and can be a starting point for your development.
CHeers
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution---
@ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.March 19, 2016 at 22:13 #111818mike1ParticipantIsn’t there a simpler way of doing this, instead of re-writing search code? The horizontal search bar works, so when a user goes to the Members page, couldn’t those search fields be pre-populated with the values the user gives when they sign up (age range, I am a…, Looking for a… etc.), and then an immediate search done from that using the built in Search feature? After that, if the user wants to adjust any of the search criteria, they can do so in the search bar. I don’t want to allow a user to change their gender or the gender they are looking for once they have signed up, so I’m sure the ‘I am a…’ & ‘Looking for a…’ fields could be hidden in the search bar, even though they are used in the search.
March 22, 2016 at 17:49 #112229AbeKeymasterwe are at the point of rewriting Sweetdate theme and making it more actual with Visual composer and better shortcodes and options.
That should be achieved this year.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution---
@ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.March 23, 2016 at 14:21 #112341mike1Participantok that’s great news, but in the meantime do you know of a way in which the search criteria can be pre populated with a member’s preferences, and then a search automatically made when the ‘Members’ page loads?
March 23, 2016 at 20:27 #112431AbeKeymasterI think it will imply some custom template changes so there isn’t a quick solution for that unfortunately.
All the best.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution---
@ SeventhQueen we do our best to have super happy customers. Thanks for being our customer. -
AuthorPosts
You must be logged in to reply to this topic.