1

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.

4 Answers 4

1

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;
}
Sign up to request clarification or add additional context in comments.

Comments

0

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

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.
0

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

This does not answer the question. The OP is asking to get the user information.
0

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/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.