Assigning a capability to Guests

I was wondering if there is a way to allow Guests to access certain capabilities (that I’m using to restrict content access).


Comments

3 responses to “Assigning a capability to Guests”

  1. 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

  2. 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;
    }
    }

  3. Hi Moises,

    Sorry but no, access restrictions can only apply to registered users.

    Kind regards,
    George

Share