Plugin Support
Kim L
(@kimmyx)
Hi @vray-admin,
Content Control restricts content generated within WordPress’ the_content() function, so post/page contents.
If your PHP file is not within this function, our plugin cannot restrict it.
Hope that helps! Let us know if you have other questions. 🙏
@vray-admin – Technically speaking yes, there are underlying functions you can call passing in the check details, with or without using out global restrictions or blocks.
You can use helper functions to check if a given post is visible to the current user based on global restrictions in the settings page, or use other helper functions to check manually user permissions such as \ContentControl\user_is_excluded() or \ContentControl\user_meets_requirements( $user_status, $user_roles = [], $role_match = 'match' )
https://github.com/code-atlantic/content-control/blob/master/inc/functions/restrictions.php#L45-L126
That said, given your simple example, you could bypass our plugin entirely:
$user = wp_get_current_user();
$allowed_roles = array( 'editor', 'administrator', 'author' );
if ( array_intersect( $allowed_roles, $user->roles ) ) {
// Stuff here for allowed roles
}