• Resolved mazeymaze

    (@mazeymaze)


    I have recently installed Advanced Cron Manager. After this I have setup a small function in functions.php that updates a page. When I init and fire directly from functions.php it works fine.

    I have setup the event “refresh_my_page” which is the function name. I get a positive response when executing it: “Event “refresh_my_page” has been executed”. But the page is not updated and the log is neither, so the cron does not fire the function.

    Below is the code I use in functions.php:

    function refresh_my_page() {
    $post_id = 111
    $my_post = array(
    ‘ID’ => $post_id,
    ‘post_content’ => get_post_field(‘post_content’, $post_id) . “\n”
    );
    wp_update_post($my_post);

    //LOG 
    $log_message = "Tried to update the ID $post_id den " . current_time('Y-m-d H:i:s') . "\n";
    error_log($log_message, 3, WP_CONTENT_DIR . '/my_custom_log.log');

    }

    If I run it directly in functions.php using the init (add_action(‘init’, ‘refresh_my_page’);) it works.

    What am I doing wrong in the plugin?

Viewing 1 replies (of 1 total)
  • Plugin Author Kuba Mikita

    (@kubitomakita)

    The event name is not a function name, but an action name.

    So you should have:

    add_action('refresh_my_page', 'refresh_my_page');
Viewing 1 replies (of 1 total)
  • The topic ‘Plugin states to have fired cron, but function is not fired’ is closed to new replies.