I am using Buddypress for groups on my website. I have the Single Member Profile View for the WPLMS > Buddypress settings set to Teachers Only (which I want to keep).
Buddypress gives the option to assign members of a group as a Group Administrator. I want to make it so Group Administrators will be able to see Single Member Profiles even if a user's site role is Student.
If you could just point me in the direction of where the logic is for restricting the Single Member Profile View is I am sure I can whip something up myself, just looking to understand it.
Thank you and have a great day!
hello,
pardon me, i did not understand. please share some screenshots.
are you asking about the coding kinds of stuff?
Hey Logan,
Yeah, I am interested in the code responsible for restricting a student from viewing another student's member profile. I want to edit it so that it allows a Group Administrator to view as well.
Screenshot of the settings I am talking about: https://imgur.com/mtp7Y25
refer: https://share.getcloudapp.com/OAur05lv
try something like this:
Don't allow anyone to visit subscriber profiles.
disallow-access-to-subscriber-profiles.php
add_action( 'wp_head', function() {
if ( bp_is_user() ) {
$user_meta = get_userdata( bp_displayed_user_id() );
if ( in_array( 'subscriber', $user_meta->roles ) ) {
wp_redirect( home_url() );
exit;
}
}
}, 1 );
get an idea from here as well.
refer:
https://wordpress.stackexchange.com/questions/53573/how-to-only-allow-users-to-view-their-own-buddypress-profiles
Hey Logan,
This is kind of the opposite of what I want to achieve, I do not want a user to be redirected if they have a certain role. Right now they do.
Thank you!
hello,
with this setting: https://imgur.com/mtp7Y25
only the instructor could check the profile of others, it could be of student or instructor profile.
or you could use admin only. it will restrict for everyone.
Hello logan,
Yes, that is setting I am interested in. Where is the code for that setting?
The issue is that I want a custom role to NOT be restricted to view profiles.
Hello,
this code is written in theme and running on a hook.
here: https://share.getcloudapp.com/7KuRmvOb
add more options here then manage the role and capabilities.