I have 3 user roles: role1, role2 and admin. I have 3 divs and a different one should show depending on the logged in persons role. So role1 should see div1 only, role2 should see div2 only and admin should see both.
How do I also display both to non-logged in users? I dont how to write that ie. target people that aren't logged in.
<?php 
    global $user_login, $current_user; 
    if (is_user_logged_in()) {
    get_currentuserinfo();
    $user_info = get_userdata($current_user->ID);
    if (in_array('role1', $user_info->roles)) { 
?>    
    <div class="div1">CONTENT</div></a>
<?php
 }
  }
?>  
<?php 
    global $user_login, $current_user; 
    if (is_user_logged_in()) {
    get_currentuserinfo();
    $user_info = get_userdata($current_user->ID);
    if (in_array('role2', $user_info->roles)) { 
?> 
    <div class="div2">CONTENT</div>
<?php
 }
  }
?>  
<?php 
    global $user_login, $current_user; 
    if (is_user_logged_in()) {
    get_currentuserinfo();
    $user_info = get_userdata($current_user->ID);
    if (in_array('administrator', $user_info->roles)) { 
?> 
    <div class="div1">CONTENT</div>
    <div class="div2">CONTENT</div>
<?php
 }
  }
?>  
 
    