rcp_user_can_access()

Note: This is part of the developer docs and is considered custom code.
Unfortunately, we cannot provide support for custom code at this time as we do not have the additional resources that would be necessary to provide support for custom code. 

If you need assistance with this, please reach out to our list of consultants for further assistance:
https://codeable.io/developers/restrict-content-pro/

rcp_user_can_access( $user_id = 0, $post_id = 0 )

This function can be used to determine if a specific user has access to specific content. All restriction options are checked with this function, so this is the most accurate way to determine if a member has access to the content.

Parameters:

  • $user_id - ID of the user to check.
  • $post_id - ID of a post to check access for.

Return values:

  • true if the given user can access the post.
  • false if the given user does not have access to view the post.

Example usage:

if( rcp_user_can_access( get_current_user_id(), get_the_ID() ) ) {
	// user can access
} else {
	// user cannot access
}
Powered by Zendesk