I need a cron job to execute the following url
http://www.mywebsite.com/wp-admin/admin.php?page=myvideoblog/mvb_main.php&action=processfeed&updatefeed=67
The problem is that it requires to be logged in as admin, what are my options? I’ve tried a few plugins but they use hooks instead of just executing a url and the cron jobs provided by the control panel does not log in to the website.
Your option using WP internals would be to use the HTTP API along with wp schedule event
Create a scheduled event, something like:
register_activation_hook(__FILE__, 'my_schedule');
add_action('execute_my_url', 'do_this_daily');
function my_schedule() {
$timestamp = //some time you want it to run
wp_schedule_event($timestamp, 'daily', 'execute_my_url');
}
function do_this_daily() {
wp_remote_get( '../ =myvideoblog/mvb_main.php&action=processfeed&updatefeed=67', $args);
}
This is a simple example please refer to the codex for additional techniques and/or arguments.
- HTTP API
- wp schedule event
It’s important to note WP cron only triggers when someone visits your WordPress site, fora true stateless cron you would need to use something at the server level or a better wrapper.