Have you ever used the WordPress Importer tool to import posts/page?
By default, the importer tool works fairly well. However, recently we were importing posts to a server for a site that has thousands of users. Time and time again as we tried to select the user from the dropdown the script literally crashed our web browser.
So, we had to find a solution and here we will show you how. We just need to insert 1 line of code to make all this work.
Note: For our site in question only editors and above can post articles. If your site allows anonymous or subscribers to post ie guest posting then this won’t work for you.
Got to /wp-content/plugins/wordpress-importer/class-wp-import.php at line #302
echo ' ' . wp_dropdown_users( array( 'name' => "user_map[$n]", 'id' => 'imported_authors_' . $n, 'multi' => true, 'show_option_all' => __( '- Select -', 'wordpress-importer' ), 'show' => 'display_name_with_login', 'echo' => 0, 'role__in' => ['author', 'editor', 'administrator'], ) );
The line we need to add is the last line. ‘role__in’. Inside the array you can add any user role that your site has.
We are working on an update to this outdated plugin that has other features that should by default, come with it.
We hope you find this article useful and remember to always backup and backup the backup. Don’t forget to change back your settings after you are done running your script.
Need help with your WordPress site? Contact Us for a FREE quote.