
Untitled
By: a guest on
Aug 1st, 2012 | syntax:
None | size: 0.59 KB | hits: 9 | expires: Never
Wordpress : Page that can be viewed only by members and if not a member than show them a registration page
function get_user_role()
{
global $current_user;
$user_roles = $current_user->roles;
$user_role = array_shift($user_roles);
return $user_role;
}
<?php
if(is_user_logged_in())
{
switch(get_user_role())
{
case 'customer' :
//CUSTOMER DISPLAY
break;
case 'subscriber' :
//SUBSCRIBER DISPLAY
break;
default :
//OTHER TYPE OF USER DISPLAY
}
}
else
{
//NO LOGGED USER DISPLAY
}
?>