Skip to content

Instantly share code, notes, and snippets.

@landbryo
Created December 13, 2019 23:21
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save landbryo/faa352f5a87e42ed43f9f16a65061350 to your computer and use it in GitHub Desktop.
Save landbryo/faa352f5a87e42ed43f9f16a65061350 to your computer and use it in GitHub Desktop.
<?php
/**
* Require user to have access level to view BuddyPress page
*/
add_filter( 'rcp_member_can_access', function ( $can_access ) {
$access_level = 4;
$page_slug = 'activity';
$customer = rcp_get_customer_by_user_id( get_current_user_id() );
if ( empty( $customer ) ) {
return $can_access;
}
global $post;
if ( $post->post_name == $page_slug && ! $customer->has_access_level( $access_level ) ) {
$can_access = false;
}
return $can_access;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment