• Resolved Rhapsody348

    (@rhapsody348)


    Your plugin is great as I’ve been using it for the past few years on my multisite installation that currently has version 1.20.3.1 installed. I have a suggestion for two simple changes I’ve made on the file classes/import.php to prevent occasional error log entries and provide more robust error handling. Please consider making the following changes in a future update.

    **** Improved error handling that prevents white screen on wp_die *****
    Line 218 import.php change from:
    wp_die( __( 'Error, we cannot find the file', 'import-users-from-csv-with-meta' ) . ": $path_to_file" );

    Line 218 import.php change to the following and insert additional lines:

    if ( !$_FILES['uploadfile']['name']) echo "<script>alert('No file was selected');</script><meta http-equiv='refresh' content='0'>";
    
    if ( $_FILES['uploadfile']['name']) echo '<br><h3><b>Refresh the page when ready, or navigate to another desired page</b></h3><input type="button" value="Refresh" onClick="window.location.href=window.location.href">';
    
    exit;

    **** Eliminates error log entry on blank or invalid email but shows on screen error *****
    Line 567 import.php change from:
    $user_id = wp_create_user( $username, $password, $email );

    to the following:
    if( !empty( $email ) && ( ( sanitize_email( $email ) !== '' ) ) ) $user_id = wp_create_user( $username, $password, $email ); // prevent insertion of blank or invalid email

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Javier Carazo

    (@carazo)

    @rhapsody348,

    The first change wasn’t consistent with the UX of the plugin, so I’ve followed your idea but adapted it to something more in line with how we usually display things.

    Regarding the second change it is not necessary because this check is previously executed on lines 426 onwards.

    Thank you very much for your help.

    Thread Starter Rhapsody348

    (@rhapsody348)

    Thanks Javier – the update works great. I missed that you had previously incorporated the blank email in earlier update.

    Question on the UI – Is there a hook I can get after the successful file upload so that I may do the equivalent of the following?

    if ( $_FILES['uploadfile']['name']) echo '<br><h3><b>Refresh the page when ready, or navigate to another desired page</b></h3><input type="button" value="Refresh" onClick="window.location.href=window.location.href">';
    
    exit;
    Plugin Author Javier Carazo

    (@carazo)

    There is a hook after the process is finished:

    do_action( ‘acui_after_import_users’, $users_created, $users_updated, $users_deleted, $users_ignored );

    I don’t understand the hook you propose.

    Thread Starter Rhapsody348

    (@rhapsody348)

    Thanks Javier. That hook works for what I want to accomplish.

    I created a page visible only for certain users in a custom admin role I created. The page provides import directions and uses the shortcode [import-users-from-csv-with-meta role=”subscriber”]’ to enable the UI for import.

    After the import I want to add a note to the user at the bottom of the screen so users may review the imported data on the screen, make any corrections as needed to the CSV file, then press the Refresh Button that I create after the importer is executed to refresh the screen and bring back the Import file chooser button.

    FYI – I did look for a hook at this link but it was not listed: https://codection.com/import-users-csv-meta/listado-de-hooks-de-import-and-exports-users-and-customers/

    Plugin Author Javier Carazo

    (@carazo)

    Yes, I have to update this page.

    Anyway if you surfer into the code and look for do_action and apply_filters functions you will see every hook that is executed.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Proposed Fix for Occasional Error Log Entries’ is closed to new replies.