WordPress.org

Forums

Call to undefined function wp_insert_link() When Using wp_schedule_event (5 posts)

  1. plumwd
    Member
    Posted 4 years ago #

    I am working on a plugin that allows for insertion of links to the wordpress database.

    When I explicitly run the plugin from inside my admin panel it runs successfully no problem. However, when running the plugin via scheduled_events it fails and I get the following error:

    PHP Fatal error: Call to undefined function wp_insert_link()

    The scheduled_events are running no problem when they should (hourly), so I know that action was set up successfully.

    Code fails on this line:

    $link_id	= wp_insert_link( $linkdata );  //insert or update our link

    Want to note that the scheduled event is calling the same function that is called from my action in the admin panel.

  2. plumwd
    Member
    Posted 4 years ago #

    Is there anyone who can help me? Is it because the function is not being called in context of the admin panel?

  3. plumwd
    Member
    Posted 3 years ago #

    Anyone?

  4. Jackson
    Member
    Posted 3 years ago #

    I would try adding this above the problematic line:

    if( !function_exists( 'wp_insert_link' ) )
        include_once( ABSPATH . '/wp-admin/includes/bookmark.php' );
  5. plumwd
    Member
    Posted 3 years ago #

    That works, thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.