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;
}
1 Answer
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
}