wp_update_user outside wordpress (cron task)
-
Hi WP comunnity,
I’m having an issue updating a user website field, by running a php script with a cron task (not wp-cron). It’s not working and returns an error while the same script is working from a web browser.
The file :
<?php require_once(__DIR__ . "/../wp-config.php"); $user_id = (int) '12345'; $website = 'http://website.com'; echo 'Test for user '.$user_id.' - '; $result = wp_update_user( array( 'ID' => $user_id, 'user_url' => $website ) ); if ( is_wp_error( $result ) ) { $error_string = $result->get_error_message(); echo 'ERROR : '.$error_string; } else { echo 'DONE'; } ?>Running this file from a web browser returns :
Test for user 12345 - DONERunning this file from a CRON task returns :
Test for user 12345 - ERROR : Cannot create a user with an empty login name.I don’t understand why it is working in one case and not in the other case.
Can someone help me please ?Thank you,
GB
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘wp_update_user outside wordpress (cron task)’ is closed to new replies.