Hide author info in single posts by certain users

Question

I use this code to add custom CSS if single post and in certain categories:

function hide_author() {
    global $post;
    if (is_single($post->ID) && in_category(array( 'category 1', 'Category 2'), $post->ID)) {
            ?>
    <style type="text/css">
.author-info {display: none;}
    </style> 
    <?php
    }
}
add_action('wp_head', 'hide_author');

I was wondering how to fire wp_head action if single post by certain users (either by user ID or username)? Can I use wp_set_current_user ()? if so, how to use it exactly?

Thanks,

0
, , Ismail Elfa 2 years 2020-06-18T22:10:21-05:00 0 Answers 92 views 0

Leave an answer

Browse
Browse