我在我的网站上为不同的用户设置了不同的按钮,我使用了下面的代码来创建这些按钮。
<?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\';
}
?>
代码对我很有用,但当我在网站中启用缓存(使用w3 total cache)时,按钮也会为不同的用户角色缓存?有没有更好的方法来实现这一点?请帮帮我
感谢并再次感谢Sanand RK