Replies
- Ravi on May 26, 2022 at 10:49 am in reply to: [Resolved] Restrict activity commenting by role? #45098
Hello Amanda,
Thank you for the acknowledgement. I am glad that I could help you.
Regards
Ravi - Ravi on May 25, 2022 at 10:13 am in reply to: [Resolved] Restrict activity commenting by role? #45084
You can place this code in the ‘bp-custom.php’ file.
Please have a look at the resource URL: https://buddydev.com/docs/buddypress-guides/what-is-bp-custom-php/
Regards
Ravi - Ravi on May 25, 2022 at 10:12 am in reply to: [Resolved] Restrict activity commenting by role? #45083
Hello Amanda,
Try the following code:
/** * Check weather user is restricted from commenting. * * @param int $user_id User id. * * @return bool */ function buddydev_is_restricted_commenter( $user_id ) { // Never restrict super admin from commenting or no user found. if ( is_super_admin( $user_id ) ) { return false; } $user = get_user_by( 'id', $user_id ); // Roles those will be restricted. $restricted_roles = array( 'contributor', 'subscriber' ); // Restrict only if the user has restricted roles. if ( $user && array_intersect( $user->roles, $restricted_roles ) ) { return true; } return false; } /** * Check user can comment or not. * * @param bool $can Bool. * * @return bool */ function buddydev_user_can_comment( $can ) { $activity = new BP_Activity_Activity( bp_get_activity_id() ); $user_id = get_current_user_id(); // Do not restrict for its own activity. if ( $activity->user_id == $user_id ) { return $can; } if ( buddydev_is_restricted_commenter( $user_id ) ) { $can = false; } return $can; } add_filter( 'bp_activity_can_comment', 'buddydev_user_can_comment' ); add_filter( 'bp_activity_can_comment_reply', 'buddydev_user_can_comment' );
Please give it a try.
Regards
Ravo - Ravi on May 24, 2022 at 8:20 am in reply to: [Resolved] Restrict activity commenting by role? #45066
Hello Amanda,
Please replace the function with the followingone :
/** * Check weather user is restricted from commenting. * * @param int $user_id User id. * * @return bool */ function buddydev_is_restricted_commenter( $user_id ) { // Never restrict super admin from commenting or no user found. if ( is_super_admin( $user_id ) ) { return false; } $user = get_user_by( 'id', $user_id ); // Roles those will be restricted. $restricted_roles = array( 'contributor', 'subscriber' ); // Restrict only if the user has restricted roles. if ( $user && array_intersect( $user->roles, $restricted_roles ) ) { return true; } return false; }
Regards
Ravi- This reply was modified 2 years, 7 months ago by Ravi.
- Ravi on May 24, 2022 at 5:06 am in reply to: [Resolved] Restrict activity commenting by role? #45064
Hello Amanda,
Welcome to the BuddyDev forums. You can replace the following function
bp_has_member_type( get_current_user_id(), 'student' );
with
// Replace the capability with role's capability you want to restrict current_user_can( 'edit_posts' );
For role-based capability check the following URL.
Reference URL: https://wordpress.org/support/article/roles-and-capabilities/Regards
Ravi- This reply was modified 2 years, 8 months ago by Ravi.
Hello Amsi,
Thank you for posting. Are you referring to the BuddyPress Member Types Pro plugin?. If yes, please let me know which theme and template pack you are using so that I can check.
Regards
RaviHello Laurent,
Sorry for the inconvenience. Please let me know which template pack and theme you are using?.
Regards
RaviHello,
Thank you for posting. Please check ‘content-single-forum.php’ bbPress uses to list topics on the single forum page. Please get in touch with your theme author to better assist you with this requirement.
Regards
RaviHello Lisa,
Thank you for posting. Branded Login plugin does not deal with the registration. BuddyPress does offer Policy acceptance with Nouveau template pack. Please let me know which template pack you are using. Please navigate to Dashboard > Settings > BuddyPress > Options > Main settings > Template pack.
Regards
Ravi- Ravi on May 11, 2022 at 4:17 am in reply to: [Resolved] Hiding “whats-new-form” in member activity but NOT in Groups #44905
Hello Yuriix,
Thank you for the acknowledgement. I am glad that I could help.
Regards
Ravi