Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 1st, 2012  |  syntax: None  |  size: 0.59 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Wordpress : Page that can be viewed only by members and if not a member than show them a registration page
  2. function get_user_role()
  3. {
  4.     global $current_user;
  5.  
  6.     $user_roles = $current_user->roles;
  7.     $user_role = array_shift($user_roles);
  8.  
  9.     return $user_role;
  10. }
  11.        
  12. <?php
  13. if(is_user_logged_in())
  14. {
  15.     switch(get_user_role())
  16.     {
  17.         case 'customer' :
  18.             //CUSTOMER DISPLAY
  19.         break;
  20.         case 'subscriber' :
  21.             //SUBSCRIBER DISPLAY
  22.         break;
  23.         default :
  24.             //OTHER TYPE OF USER DISPLAY
  25.     }
  26. }
  27. else
  28. {
  29.     //NO LOGGED USER DISPLAY
  30. }
  31. ?>