Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6940765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:47:42+00:00 2026-05-27T12:47:42+00:00

It just doesn’t work and I have no idea what’s wrong. Maybe someone can

  • 0

It just doesn’t work and I have no idea what’s wrong. Maybe someone can help me.
Here is my code:

add_action('kawabunga',function(){
    echo '<h1>KAWABUNGA!!!!1</h1>';
});


if (!wp_next_scheduled('kawabunga')) {
    wp_schedule_single_event(time()+120, 'kawabunga');
}

Then I used this code to look at what’s happening with a task:

echo 'scheduled = ' . wp_next_scheduled('kawabunga');
echo '<br>time = ' . time();

And it acted as I expected: first displayed both timestamps and in 2 minutes only the second one, because an action was executed and it wasn’t scheduled anymore so it returned “false”, not a timestamp.
But my function wasn’t actually executed, it didn’t print <h1>KAWABUNGA!!!!1</h1> and my IDE didn’t stop on the breakpoint.

I also tested an action in other part of the site: do_action('kawabunga'); and it worked just fine. It doesn’t work only in cron.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:47:43+00:00Added an answer on May 27, 2026 at 12:47 pm

    Aurimas is right, you need to define a function that can be called in a later request. So using an anonymous function will not work here.

    I believe that cron processing is triggered after page output, so as not to slow down the user’s experience. Outputting an won’t have any effect. You would be better to test with a call to mail() or wp_mail() (or write to a file if mail doesn’t work on your system).

    With those two corrections, your code looks good.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My knowledge of code just doesn't go this deep, and I have no idea
I have tried the following code in many ways but it just doesn't work.
I have this code, it works but it just doesn't look right. I'm creating
I have a problem with my coding. My code just doesn't seem to be
Maybe it's just doesn't exist, as I cannot find it. But using python's logging
Rails is a great platform, but it just doesn't have the history that Perl
It doesn't really have to add newlines, just something readable. Anything better than this?
I must be making some obvious mistake but it just doesn't seem to work.
Do Hibernate Projection aliases even work? I could swear it just doesn't. At least,
I know this has been asked before, but it just doesn't work for me.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.