I am having different buttons for different users in my site, i have used the below code to create those.
<?php
global $user_login, $current_user;
get_currentuserinfo();
$user_info = get_userdata($current_user->ID);
$roles = array (
'administrator',
'daily',
'monthly',
'unlimited',
);
$roles_expired = array (
'expired',
);
if (is_user_logged_in() && array_intersect( $roles, $user_info->roles)) {
echo Button 1;
} else if (is_user_logged_in() && array_intersect( $roles_expired, $user_info->roles)) {
echo 'Button2';
}
else {
echo 'Button3';
}
?>
The code is working for me, but when i enable caching(using w3-total-cache) in the website the button is also cached for different user roles also?
is there a better way to implement this ? Please help me
Thanks and Regards Anand RK