Support » Plugin: Import Users from CSV » [Plugin: Import Users from CSV] Import via cron event

  • ResolvedPlugin Author Ulrich Sossou


    How to schedule a cron event that will import users from a specified file on the server?

    I had a user ask me by email how to do that, so I released version 0.5 to make the plugin more extensible and I am posting the solution here for anyone who would like to do that in the future.

    The plugin now has a function called IS_IU_Import_Users::import_csv( string $filename, bool, bool ).
    The first argument is the path to the file on the server.
    The second one is whether you want the password nag to be shown on first user login.
    The third one is whether you want to send email notifications to the new users.

    Below is the code to schedule the daily event.

    function is_iu_schedule_event() {
        if ( ! wp_next_scheduled( 'is_iu_daily_event' ) ) {
            wp_schedule_event( time(), 'hourly', 'is_iu_daily_event' );
    add_action( 'wp', 'is_iu_schedule_event' );
    function is_iu_do_this_daily() {
        IS_IU_Import_Users::import_csv( PATH_TO_YOUR_CSV_FILE );
    add_action( 'is_iu_daily_event', 'is_iu_do_this_daily' );

    This code can be added to a plugin or your theme functions.php file
    Make sure to replace PATH_TO_YOUR_CSV_FILE with the actual path to your csv file on the server.

Viewing 2 replies - 1 through 2 (of 2 total)
  • This is cool.

    How to make this to update the existing users (except password)? and add new users not already in the database?

    Plugin Author Ulrich Sossou


    Add an ID column in your CSV and put the ID for existing users in there

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Import Users from CSV] Import via cron event’ is closed to new replies.