Support » Plugins » Hacks » Call to undefined function wp_insert_link() When Using wp_schedule_event

  • 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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Is there anyone who can help me? Is it because the function is not being called in context of the admin panel?

    plumwd

    (@plumwd)

    Anyone?

    Jackson

    (@madjax)

    I would try adding this above the problematic line:

    if( !function_exists( 'wp_insert_link' ) )
        include_once( ABSPATH . '/wp-admin/includes/bookmark.php' );
    plumwd

    (@plumwd)

    That works, thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Call to undefined function wp_insert_link() When Using wp_schedule_event’ is closed to new replies.