CSV User Import & Welcome Email
Import users from CSV, track imported status, and send welcome emails manually. Professional OOP-based plugin with custom admin interface.
by Your Name · github.com/therehmandev/csv-user-import-welcome-email · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/therehmandev/csv-user-import-welcome-email/archive/refs/heads/master.zipReadme
CSV User Import & Welcome Email Plugin
A professional WordPress plugin that allows CSV import of users, tracks imported user metadata, displays them in a custom admin table with statistics, and enables manual triggering of existing custom welcome email functions per user.
Features
- CSV User Import: Upload and parse CSV files to create WordPress users
- User Metadata Tracking: Automatically assigns
_imported_usermeta field to imported users - Manual User Email Tracking: Tracks manually created users for welcome email management
- Automatic Email Suppression: Prevents automatic emails when users are manually created
- Custom Admin Interface: Professional admin page with tabbed interface
- Statistics Dashboard: Real-time statistics showing import counts, manual users, and email status
- Welcome Email Integration: Integrates with existing
send_custom_welcome_email()function - Individual Email Sending: Send welcome emails to individual users via admin interface
- Search & Filtering: Advanced user table with search and filter capabilities
- Import Logging: Comprehensive logging of import operations and email sending
- Security: Nonce verification, capability checks, and file validation
Requirements
- WordPress 5.0 or higher
- PHP 7.4 or higher
- Existing
send_custom_welcome_email($user_id)function in your theme or plugin
Installation
- Upload the
csv-user-import-welcome-emailfolder to your/wp-content/plugins/directory - Activate the plugin through the 'Plugins' menu in WordPress
- Navigate to Users → Imported Users to access the plugin interface
CSV Format
The plugin expects CSV files with the following columns:
| Column | Required | Description |
|---|---|---|
| username | Yes | Unique username for the user |
| Yes | Valid email address | |
| first_name | No | User's first name |
| last_name | No | User's last name |
| password | No | User password (generates random if empty) |
Sample CSV
username,email,first_name,last_name,password
john_doe,john.doe@example.com,John,Doe,password123
jane_smith,jane.smith@example.com,Jane,Smith,
mike_wilson,mike.wilson@example.com,Mike,Wilson,securepass456
Usage
Importing Users
- Go to Users → Imported Users
- Click the Import Users tab
- Upload your CSV file
- Optionally check "Send Welcome Emails" to automatically send emails
- Click Import Users
Managing Users
- Go to Users → Imported Users
- Click the Imported Users tab
- View statistics and user list
- Use search and filters to find specific users
- Send welcome emails individually or in bulk
Available Filters
The plugin provides several filtering options to help you manage users:
- All Users: Shows all users in the system
- Imported Users Only: Shows only users imported via CSV
- Manually Created Users Only: Shows only users created through the WordPress dashboard
- Email Eligible Users: Shows users who can receive welcome emails (imported + manual)
- Non-tracked Users Only: Shows users not in the email tracking system
Sending Welcome Emails
Individual Emails
- Each eligible user row has a "Send Welcome Email" button
- Available for both imported users and manually created users
- Click to send a welcome email to that specific user
- Button updates to show "Email Sent" after successful sending
Manual User Creation
When you manually create users through the WordPress dashboard:
- No automatic emails are sent (WordPress core notifications are suppressed)
- Users are automatically tracked for welcome email management
- "Send Welcome Email" button appears for manually created users
- Users appear in statistics under "Manually Created Users"
This ensures consistent email management regardless of how users are created.
Technical Details
Database Tables
The plugin creates two custom tables:
wp_csv_uiwe_import_log
- Tracks CSV import operations
- Records success/failure status
- Stores error messages for failed imports
wp_csv_uiwe_email_log
- Logs welcome email sending attempts
- Tracks success/failure status
- Stores error messages for failed emails
User Meta
_imported_user: Set to "1" for imported users, "0" or null for others
Hooks and Filters
Actions
csv_uiwe_user_imported: Fired when a user is successfully importedcsv_uiwe_welcome_email_sent: Fired when a welcome email is sentcsv_uiwe_import_completed: Fired when CSV import is completed
Filters
csv_uiwe_csv_columns: Modify CSV column requirementscsv_uiwe_user_data: Modify user data before creationcsv_uiwe_import_validation: Custom validation rules
API Functions
CSV_UIWE_CSV_Importer
import_users($file, $send_welcome_emails): Main import function
CSV_UIWE_Email_Sender
send_welcome_email($user_id): Send welcome email to specific usersend_bulk_welcome_emails($user_ids): Send emails to multiple usershas_welcome_email_been_sent($user_id): Check email status
CSV_UIWE_Users_Table
- Extends
WP_List_Tablefor custom user display - Handles pagination, sorting, and filtering
Security Features
- Nonce Verification: All form submissions and AJAX requests
- Capability Checks: Requires
manage_optionscapability - File Validation: MIME type and size restrictions
- Input Sanitization: All user inputs are properly sanitized
- SQL Prepared Statements: Database queries use prepared statements
Customization
Styling
Modify assets/css/admin.css to customize the appearance of the admin interface.
JavaScript
Extend assets/js/admin.js to add custom functionality or modify existing behavior.
Email Function Integration
Ensure your send_custom_welcome_email($user_id) function:
- Accepts a user ID parameter
- Returns true on success, false on failure
- Handles errors gracefully
- Is available when the plugin is active
Troubleshooting
Common Issues
-
"Custom welcome email function not found"
- Ensure
send_custom_welcome_email()function exists - Check function name spelling and availability
- Ensure
-
Import fails with "Invalid file type"
- Verify file has .csv extension
- Check file MIME type
- Ensure file size is under 2MB
-
Users not appearing in table
- Check user meta
_imported_uservalue - Verify database table creation
- Check for JavaScript errors in browser console
- Check user meta
-
Welcome emails not sending
- Test the
send_custom_welcome_email()function independently - Check email server configuration
- Review error logs for specific error messages
- Test the
Debug Mode
Enable WordPress debug mode to see detailed error messages:
// In wp-config.php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
Support
For support and feature requests:
- Check the troubleshooting section above
- Review WordPress error logs
- Test with a minimal CSV file
- Verify all requirements are met
Changelog
Version 1.0.0
- Initial release
- CSV user import functionality
- Welcome email integration
- Custom admin interface
- Statistics dashboard
- Import and email logging
License
This plugin is licensed under the GPL v2 or later.
Credits
Developed as a professional WordPress plugin following WordPress coding standards and best practices.