SHARE
TWEET

php snippet user role conditional logic

a guest Mar 27th, 2012 201 Never
  1. <?php
  2. $user_roles = $current_user->roles;
  3. $user_role = array_shift($user_roles);
  4. ?>
  5.  
  6. <?php if ($user_role == 'administrator') {
  7.      echo do_shortcode('[enter download-monitor shortcode here]'); }  
  8.                          
  9. elseif ($user_role == 'editor') {
  10.      echo do_shortcode('[enter download-monitor shortcode here]'); }  
  11.                          
  12. elseif ($user_role == 'media_access') {
  13.      echo do_shortcode('[enter download-monitor shortcode here]'); }  
  14.                        
  15. elseif ($user_role == 'retailer_access') {
  16.      echo do_shortcode('[enter download-monitor shortcode here]'); }  
  17.                        
  18. elseif ($user_role == 'internal_access') {
  19.      echo do_shortcode('[enter download-monitor shortcode here]'); }  
  20.  
  21. elseif ($user_role == 'all_vars_access') {
  22.      echo do_shortcode('[enter download-monitor shortcode here]'); }  
  23.                        
  24. elseif ($user_role == 'checkpoint_access') {
  25.      echo do_shortcode('[enter download-monitor shortcode here]'); }  
  26.                          
  27. ?>
RAW Paste Data
Top