WordPress.org

Ideas

WP Cron functions need Class Hook support

  1. therealwesfoster
    Inactive

    12345

    All of the WP built-in cron (scheduling) functions require a string for the hook. This causes a problem when trying to call a function from within a class.

    With most functions, you can use array(&$this, 'function_name'), however you cannot do this with WP's schedule functions.

    http://wordpress.org/support/topic/illegal-offset-type-when-using-wp_schedule_event

    Thanks!

    Posted: 5 years ago #
  2. joelworsham
    Inactive

    Agree

    Posted: 2 years ago #
  3. flymike
    Member

    This is because an action is being scheduled rather than any function.
    When the scheduled event fires, there must be a function (or class::method) hooked onto the action - or nothing will happen.
    See the example at https://codex.wordpress.org/Function_Reference/wp_schedule_single_event

    Posted: 8 months ago #
  4. therealwesfoster
    Inactive

    12345

    Excellent answer, flymike. Even better because today is #ThrowbackThursday and I am able to re-live my original question from 4 years ago. Time flies!

    Well done.

    Posted: 8 months ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    10 Votes
  • Status

    This idea is under consideration