I was wondering if there is a way to allow Guests to access certain capabilities (that I’m using to restrict content access).
Assigning a capability to Guests
Posted in Groups Restrict Categories
I was wondering if there is a way to allow Guests to access certain capabilities (that I’m using to restrict content access).
Follow us! We post news and tutorials related to our tools, WordPress and WooCommerce on these platforms:
Hi Moises,
The filter groups_user_can accepts 3 parameters one of which is user object. If the user is not logged in, then there is no user obj.
Kind regards,
George
I know I might be simplifying the code but would something similar to this would work?
add_filter( ‘groups_user_can’, ‘my_force_cap’, 1, 3);
function my_force_cap(){
if (!is_user_logged_in()){
return true;
}
}
Hi Moises,
Sorry but no, access restrictions can only apply to registered users.
Kind regards,
George