Replies
- calu on August 17, 2021 at 1:09 pm in reply to: [Resolved] How do I change this Privacy Policy link on the register page? #40109
Hi Brajesh, now that we are at the different BP core settings, can you explain exactly what BuddyPress to WordPress profile syncing does, in the Dashboard Options settings, and whether I should I mark it on or not? I haven’t been able to find a clear answer to this so far.
Regards
Carsten - calu on August 17, 2021 at 10:34 am in reply to: [Resolved] How do I change this Privacy Policy link on the register page? #40106
Hi Brajesh, thanks for the guidance
Regards
Carsten - calu on August 11, 2021 at 6:09 pm in reply to: Member Types Pro and use of associated avatars #40028
Hello Ravi, that’s fine, blocks is the only way I can add widgets now, the old widget layout has gone.
Regards
Carsten - calu on August 11, 2021 at 10:21 am in reply to: Member Types Pro and use of associated avatars #40023
Hello Ravi, apparently there are two sets of BP Block Widgets, but only one of the sets are filtered by the Gender Based Member Filter:
What seems to be the core BP blocks are not:
What is the difference between the two sets of BP Block Widgets, obviously there is a difference?
Regards
Carsten - calu on August 11, 2021 at 10:05 am in reply to: Member Types Pro and use of associated avatars #40022
Hi Ravi, thanks for looking into this and for solving this issue for me.
I wasn’t aware of the required thumbnail avatar, so now it is working perfectly!
The only issues which remains, is that the BP widget avatars are not following members loop, or the gender based member filter below?
How do I make the code work on BP widgets as well?
Regards
Carsten/** * Filters Users based on Gender. Make sure only users of opposite genders are visible. */ class BuddyDev_Gender_Based_Member_Filter { /** * Boot * * @return BuddyDev_Gender_Based_Member_Filter */ public static function boot() { $self = new self(); $self->setup(); return $self; } /** * Setup hooks. */ private function setup() { add_filter( 'bp_after_has_members_parse_args', array( $this, 'filter_args' ) ); add_action( 'bp_template_redirect', array( $this, 'check_access' ), 10, 2 ); } /** * Modifies members loop args to filter out users of same gender. * * @param array $args Array of group allowed parameters. * * @return array */ public function filter_args( $args ) { // do not filter if user is not logged in, or is super admin or we are inside dashboard. if ( ! is_user_logged_in() || is_super_admin() || ( is_admin() && ! defined( 'DOING_AJAX' ) ) ) { return $args; } $opposite_gender = $this->get_opposite_gender( bp_loggedin_user_id() ); if ( $opposite_gender ) { $args['member_type'] = $opposite_gender; } return $args; } /** * Restricts access to user profile. * * Only allows profile owner, user of opposite gender or site admins to view. */ public function check_access() { if ( ! is_user_logged_in() || ! bp_is_user() || bp_is_my_profile() || is_super_admin() ) { return; } $gender = $this->get_user_gender( bp_loggedin_user_id() ); if ( ! $gender ) { return; } // do not allow access for same gender. if ( bp_has_member_type( bp_displayed_user_id(), $gender ) ) { bp_core_add_message( __( 'Access denied.', 'yym-helper' ) ); bp_core_redirect( bp_loggedin_user_domain() ); } } /** * Returns user Gender. * * @param int $user_id user id. * * @return string|null */ private function get_user_gender( $user_id ) { $gender = null; $member_types = bp_get_member_type( $user_id, false ); if ( empty( $member_types ) ) { $gender = null; } elseif ( $this->is_user_male( $user_id ) ) { $gender = 'male'; } elseif ( $this->is_user_female( $user_id ) ) { $gender = 'female'; } return $gender; } /** * Finds the opposite gender for the given user. * * @param int $user_id user id. * * @return string|null */ private function get_opposite_gender( $user_id ) { $user_gender = $this->get_user_gender( $user_id ); if ( ! $user_gender ) { return null; } if ( 'male' === $user_gender ) { return 'female'; } elseif ( 'female' === $user_gender ) { return 'male'; } return null; } /*** * Checks if user is male or not. * * @param int $user_id User id to check. * * @return bool */ private function is_user_male( $user_id ) { return bp_has_member_type( $user_id, 'male' ); } /*** * Checks if user is female or not. * * @param int $user_id User id to check. * * @return bool */ private function is_user_female( $user_id ) { return bp_has_member_type( $user_id, 'female' ); } } BuddyDev_Gender_Based_Member_Filter::boot();
- calu on August 11, 2021 at 12:13 am in reply to: Member Types Pro and use of associated avatars #40017This reply has been marked as private.
- calu on August 10, 2021 at 10:09 am in reply to: Member Types Pro and use of associated avatars #40004
Hi Brajesh, Thanks for helping out. I have not been able to address the issue yet, but I can see now that it is not related to MTP, as the issue persist, when using the code below I used before I started using MTP.
I have deactivated my child theme to rule out any issues there, and I have gone through my plugins, but I can’t see that any of these could affect this.
If you are willing to take a closer look on my site, please let me know, and I will send you the credentials.
Regards
Carsten//Using different default Avatar for BuddyPress //Disable Gravatar add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' ); //Using different default avatar based on BuddyPress profile field function buddydev_set_default_avatar_based_on_profile_field_data( $avatar, $params ) { $user_id = $params['item_id']; $field_id_or_name = 32;//Gender field Id, You may use field name e.g 'Gender'; //I suggest using id for performance reasons $gender = xprofile_get_field_data( $field_id_or_name, $user_id ); $gender = strtolower( $gender ); if ( $gender == 'man' ) { $avatar = 'https://wedate.dk/wp-content/uploads/2021/02/IMG_5356-e1620142850931.jpeg'; } elseif ( $gender == 'woman' ) { $avatar = 'https://wedate.dk/wp-content/uploads/2021/02/IMG_5357.jpeg'; } else { $avatar = 'https://wedate.dk/wp-content/uploads/woocommerce-placeholder.png'; } // note, you may play with the $param['type'] and use different image for full|thumb. return $avatar; } add_filter( 'bp_core_default_avatar_user', 'buddydev_set_default_avatar_based_on_profile_field_data', 10, 2 );
- calu on May 31, 2021 at 1:17 pm in reply to: [Resolved] Counter displaying pending friends requests instead #38897
Hi Brajesh, thanks for the clarification, in that case I would rather not have the counter.
How can I hide it, if I prefer a non css solution?
Regards
Carsten - calu on May 24, 2021 at 7:45 pm in reply to: Using BuddyPress Profile Completion with Member Types Pro #38800
Hi Brajesh, I do not have any custom code or plugin involving member types.
Thanks for checking this out, I appreciate it
Regards
Carsten - calu on May 24, 2021 at 2:03 pm in reply to: Using BuddyPress Profile Completion with Member Types Pro #38792
Hi Brajesh, thanks for looking into this.
“Can you please visit the Profile->Edit page and tell me if that shows the member type as selected?”
Yes it does, even if the default value has been set to None and updated. When returning to the group of fields, it has changed to the “mand” value which is then registered by default.
Regards
Carsten