linux - PHP Notice: Trying to get property 'post_author' of non-object in /DocumentRoot/wp-content/themes/workscout/functions.php on line 37

one text

In /log/php7/www-error.log

PHP Notice:  Trying to get property 'post_author' of non-object in /DocumentRoot/wp-content/themes/workscout/functions.php on line 37

PHP Notice:  Trying to get property 'post_author' of non-object in /DocumentRoot/wp-content/themes/workscout/functions.php on line 301

In functions.php

function wp_core_js() {

global $post, $userSettingsArr;

foreach ($userSettingsArr as $id => $settings) {
    if (($id == $post->post_author) && (isset($settings['js']))) { //this is line 37
        echo $settings['js'];
        break;
    }
}

and

function removeYoastMeta() {
global $userSettingsArr, $post;

$authors_ids_arr = array_keys($userSettingsArr);

if (in_array($post->post_author, $authors_ids_arr)) { //this is line 301
    add_filter('wpseo_robots', '__return_false');
    add_filter('wpseo_googlebot', '__return_false'); // Yoast SEO 14.x or newer
    add_filter('wpseo_bingbot', '__return_false'); // Yoast SEO 14.x or newer
}

I'm a newbie, so i don't khow how to fix this error. Please help me know how to fix this error.

In www-error.log file, there are still a lot of other database related errors, so i will have at least one more post to ask about this issue.

Source