2

I would really appreciate any help with my website that crashed and the following error appears

Fatal error: Call to undefined function is_user_logged_in() in /home1/zesiku/public_html/wp-includes/post.php on line 2160"

I have checked cpanel and see the following. The line that says if ( 'readable' == $perm && is_user_logged_in() ) { is the 2160. What to do :(((

function _count_posts_cache_key( $type = 'post', $perm = '' ) {
    $cache_key = 'posts-' . $type;
    if ( 'readable' == $perm && is_user_logged_in() ) {
        $post_type_object = get_post_type_object( $type );
        if ( $post_type_object && ! current_user_can( $post_type_object->cap->read_private_posts ) ) {
            $cache_key .= '_' . $perm . '_' . get_current_user_id();
        }
    }
    return $cache_key;
}
  • Have you modified WP core, and are you running the latest version of WordPress? – Tom J Nowell Apr 14 '17 at 17:11
  • Can you check once by deactivating all WordPress plugins and activating WordPress default theme? – WildProgrammers Apr 14 '17 at 17:12
  • I am unable to open the website at all and the page gives a fatal error. So all i can do is stare at the cpanel and that is high level for me :( – Zesiku Apr 15 '17 at 16:41
1

Put your code in whatever function:

function whatever(){
    // do stuff
}
add_action( 'init', 'whatever' );

Or use this to check whether user is logged in or not:

if( get_current_user_id() ) {
    // logged in user
}
  • Thank you for your help! can you please be specific where i need to paste these? – Zesiku Apr 15 '17 at 16:40
  • 1
    Hi, Here you are – MahdiY Apr 15 '17 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.