How to give guests “non login users” a role?

Question

I’m trying to give guest users “non logged in”a role.

I searched everywhere and I could find a single solution that can make that happen.
All what I found is to make if statement in function.php file to give access to sertin things, like for example post a comment without login.
But when there is a lot of roles it’s hard to make it that way and start to be complicated.

Is there anyway that I can achieve that?
Things that I have used

add_role( 'custom_role', 'Custom Role', array( 'read' => true ) );

and

 <?php
    global $user_login;
    if( $user_login ) {
    echo 'user logged in';
    } else {
    echo 'user not logged in';
    }
    ?>
0
, , N m 5 months 0 Answers 88 views 0

Leave an answer