Skip to content

Instantly share code, notes, and snippets.

@raftaar1191
Created February 27, 2023 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raftaar1191/55fe297db0724e62883846b3ed31b543 to your computer and use it in GitHub Desktop.
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
/**
* 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