0

My multisite wordpress site works the way, that if someone is not logged in, they will be redirected to wp-login.php. Unfortunately i have a cronjob, that can not run, because it is also redirected, since its not a logged in user, who runs it. How can i get this to work ? Im posting my script below. It seems like, after wp-load.php is run, i can not get anything to work.

// Include WordPress
define('WP_USE_THEMES', false);
require_once('/var/www/intranet.fo/public_html/wp-load.php');

// wp_set_auth_cookie(9);

// $creds = array();
// $creds['user_login'] = 'my_username';
// $creds['user_password'] = 'my_pw';
// $creds['remember'] = true;
// $user = wp_signon( $creds, false );
4
  • you can load wp-cron.php directly via a proper cron job, this is actually recommended by wordpress, see this answer: wordpress.stackexchange.com/a/253331/76440
    – majick
    Jul 10, 2017 at 10:36
  • are you saying that i will get rid of the not logged in redirection, by doing it this way ? Jul 10, 2017 at 12:33
  • it should bypass the user redirection because there is no user session as such to process, the WP Cron tasks are called directly instead, by calling wp-cron.php instead of wp-load.php
    – majick
    Jul 10, 2017 at 16:44
  • that sounds great, i will try it later today Jul 10, 2017 at 16:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.