我正在嘗試根據 WordPress 中的用戶名顯示一條消息。我正在使用的代碼:$current_user = wp_get_current_user();if( 'user1' && 'user2' == $current_user->user_login ){ echo "discount 20%";}else { echo "you could save 20% if you are a VIP customer";}如果我將上面的代碼與&&運算符一起使用,discount 20%則僅顯示為user2如果我使用上面的代碼 with ||operatordiscount 20%顯示給所有用戶,即使用戶未登錄。代碼與 ||$current_user = wp_get_current_user();if( 'user1' || 'user2' == $current_user->user_login ){ echo "discount 20%";}else { echo "you could save 20% if you are a VIP customer";}我會及時添加用戶名。折扣 20% 應僅顯示我將添加的用戶名。它不應顯示給其他或訪客/未登錄用戶。我在這里做錯了什么?
- 1 回答
- 0 關注
- 162 瀏覽
添加回答
舉報
0/150
提交
取消