Adding CSS classes with PHP, if the users permissions match.
-
Hello,
I’m trying to use php to add an extra class to an element only if the current users custom role is equal to ‘shopkeeper’.
__________
The current class “product_after_shop_loop_switcher”, controls a CSS animation. my aim is to add an extra class called “product_after_shop_loop_switcherOFF”, to turn the animations off.
__________
I’ve so far tried something along the lines of
<div class="product_after_shop_loop_switcher <?php if(in_array('shopkeeper', $current_user->roles)) { return ' product_after_shop_loop_switcherOFF'; } ?>">
__________
The basic idea being that if the current user is a shopkeeper, it will return the css string I need and add the class, cancelling out the animations.
Yet If they are not a shopkeeper, the class will not be added, and the animations will work as normal.
- The topic ‘Adding CSS classes with PHP, if the users permissions match.’ is closed to new replies.