Approval for only one Profile Type
-
We have two profile types – Students and Teachers. Anyone can join as a student, but we need to screen teachers.
Can this plugin be customised so we only have to approve one Profile Type?
Many thanks, great work!
-
Hi @thegrbteam
I recalled a similar request from a couple years ago here on the forums and managed to track down the code I provided for it.
function bpro_per_member_type_moderation_override( $user_id ) { $member_type = bp_get_member_type( $user_id ); // No membershipt type found, Let's not do anything. if ( false === $member_type ) { return; } // Should return an array of member types, even if only one type assigned. if ( is_array( $member_type ) ) { if ( in_array( 'type_value', $member_type, true ) ) { bp_registration_set_moderation_status( $user_id, 'false' ); } } } add_action( 'user_register', 'bpro_per_member_type_moderation_override', 11 );
Basically by default we’d just let BuddyPress Registration Options run like expected, and then with this new code snippet, we’d add some custom code to run immediately after BPRO’s code, to immediately set the status of a given type.
In the case above, the fictional
type_value
member type would be automatically approved for each user coming in.So you’d want to change that
type_value
field tostudent
or whatever the slug is for your student type.Teacher types and any others would still get left as needing approved, but students would get the free pass.
Let me know if you have any thoughts or questions about this.
Hello, thank you so much for replying. I tested this with the Snippets plugin for both of our two profiles types replacing ‘type_value’ with ‘mentee’ to be auto-approved and the other profile type is mentor (we changed slightly but same difference. Both tests the approval email came through to admin so it didn’t work.
Then I realised we’re using BuddyBoss not BuddyPress, I’m just learning of the difference and the directions both platforms have taken.
Would you expect this to work with BuddyBoss too?
function bpro_per_member_type_moderation_override( $user_id ) { $member_type = bp_get_member_type( $user_id ); // No membershipt type found, Let's not do anything. if ( false === $member_type ) { return; } // Should return an array of member types, even if only one type assigned. if ( is_array( $member_type ) ) { if ( in_array( 'mentee', $member_type, true ) ) { bp_registration_set_moderation_status( $user_id, 'false' ); } } } add_action( 'user_register', 'bpro_per_member_type_moderation_override', 11 );
-
This reply was modified 3 years, 5 months ago by
thegrbteam.
The only part of the code snippet that comes from BuddyPress/BuddyBoss is the
bp_get_member_type()
function which I’ve verified is in both platforms. Everything else is standard PHP code, or from BuddyPress Registration Options. Theuser_register
hook is WordPress core.Best answer I have right now for why it didn’t work would be if the member type isn’t assigned yet, thus that part always returning false and the rest of the snippet never getting reached.
They select the member type on the registration form: https://prntscr.com/1ud96zv
I appreciate the limits of free support so if we need to commission this we would be happy to as it’s a critical aspect to our idea for a new site.
Many thanks
I get that they choose the member type when signing up, but in terms of the code executing and actually registering the user inside the code base, is what I’m wondering about.
This part here:
$member_type = bp_get_member_type( $user_id ); // No membership type found, Let's not do anything. if ( false === $member_type ) { return; }
Wherein the
bp_get_member_type( $user_id )
call is returning false because the member type isn’t set just yet, and thus it’s exiting out before the rest of the snippet runs. If all the users are being moderated still despite membership type, then this is what I’m presently betting on being the case.I’ll try to see if I can recreate a scenario for this on my own and see if it works for me as is. I don’t have my local dev environment configured to have member types, so I’ll need to handle that detail too.
At the moment, and after some review, I feel that I can confirm that the proposed solution above is probably not going to work with BuddyBoss. They look like they do a lot more around automation and UI for member types than I have familiarity with.
It feels like there’s also a fair amount lacking on the BuddyPress side for UI around member types. Potentially left more for the site developers to make use of as they see fit. So I can’t even guarantee that the code would work with BuddyPress, unless someone has made sure that the membership type is assigned early enough for my snippet to run accurately.
Something to keep in mind is that we are aware that BuddyBoss lists us as an integration and lists it as compatible. However, thus far we have not actively tested against the BuddyBoss platform. We’ve still only focused on BuddyPress and bbPress for our active testing. Thus we have cases where we may not be as compatible as we could be, and all my support is coming from the mindset of using BuddyPress/bbPress only.
I really appreciate your efforts checking this. We’re going to get a quote for quote for a developer to work this out.
All the best
Sounds good.
-
This reply was modified 3 years, 5 months ago by
- The topic ‘Approval for only one Profile Type’ is closed to new replies.