Created
February 27, 2023 11:12
-
-
Save raftaar1191/55fe297db0724e62883846b3ed31b543 to your computer and use it in GitHub Desktop.
Add class into the body tag to check if user is login or logout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Function to add class when user is login in or not login in | |
*/ | |
function awp_body_class_callback( $classes ) { | |
$class = get_current_user_id() ? 'user-login' : 'user-logout'; | |
return array_merge( $classes, array( $class ) ); | |
} | |
add_filter( 'body_class', 'awp_body_class_callback', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment