I have wordpress theme which make and post new div with unique id for episode <div class = "post-2122 episode type-episode status-publish has-post-thumbnail hentry"> and how can i change border in css only for specific user and dependable on php variable? post-xxxx is uniquefor every episode.
Add a comment
|
4 Answers
Maybe you could also add the user ID in body_class()
add_filter( 'body_class', 'my_class_names' );
function my_class_names( $classes ) {
// add 'class-name' to the $classes array
global $current_user;
$user_ID = $current_user->ID;
$classes[] = 'user-id-' . $user_ID;
// return the $classes array
return $classes;
}
Comments
If you want to display a special border on specific user when is logged, you can try :
<?php
if ( is_user_logged_in() ) {
echo '<div class="is-logged">';
} else {
echo '<div>';
}
?>
And then apply a CSS to .is-logged
1 Comment
disinfor
This doesn't answer the question, since
is_user_logged_in() only checks if a user is logged in, not a specific user. Also, your answer should apply to the OPs code.you can use:
<div class="post-<?php $postid = get_the_ID(); ?> episode type-episode status-publish has-post-thumbnail hentry">
here is the reference how to get post id
hope your problem will be solve.!
1 Comment
disinfor
This does not answer the question. The OP is asking to get the user information.
You can use get_current_user_id() to get the logged in ID of the user.
<?php $user = 'user_' . get_current_user_id(); ?>
<div class="<?php echo $user; ?> post-2122 episode type-episode status-publish has-post-thumbnail hentry">
If the user is not logged in, $user will echo user_0, if they are logged in, $user will echo user_xx with their ID in place of xx.
Codex: https://developer.wordpress.org/reference/functions/get_current_user_id/