Allow only selected user roles with PHP
-
<?php if ( UM()->user()->get_role() == 'um_royal-crescent-apartments-jersey' || 'um_03-cobalt-quarter-jersey' || 'um_05-mistral-jersey' || 'um_28-cobalt-quarter-jersey' || 'um_113-sirocco-jersey' || 'um_220-blake-building-jersey' || 'um_237-blake-building-jersey' || 'um_a601-royal-crescent-apartments-jersey' || 'um_b304-royal-crescent-apartments-jersery' || 'um_c301-royal-crescent-apartments-jersey' ) { echo 'Jersey '; } else { echo ''; } ?>
I’m using this code to exclude certain content in a template, but it is showing these parts to anyone. If I just have one user role it works perfectly. I thought || is OR, I’ve try xor too. What have I missed?
I have multiple logins to test this.
<?php if ( UM()->user()->get_role() == 'um_royal-crescent-apartments-jersey' ) { echo 'Jersey '; } else { echo ''; } ?>
This works on it’s own with one role
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Allow only selected user roles with PHP’ is closed to new replies.