Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/gabrielgpacheco/woocommerce-registration-notifier/archive/refs/heads/main.zipRegistration Notifier for WooCommerce - v5.0.0
A modern, WPCS-compliant WordPress plugin that captures custom registration fields (name, phone) in WooCommerce registration and sends notification emails with configurable SMTP.
Features
✅ Custom Registration Fields
- Full name (required)
- Phone number with area code (required, validated)
✅ Email Notifications
- Admin receives notification on new user registration
- HTML email template with user details
- Configurable recipient email
✅ SMTP Configuration
- Custom SMTP server settings (host, port, authentication)
- Encryption support (TLS/SSL)
- Graceful fallback to WordPress default mail
- Test email functionality
✅ Code Quality
- 100% WPCS compliance
- OOP architecture with proper namespacing
- Security hardening (nonces, sanitization, escaping)
- Full PHPDoc documentation
- Internationalization support (i18n)
Requirements
- PHP: 7.4 or higher
- WordPress: 5.0 or higher
- WooCommerce: Latest version
- PHPMailer: Bundled with WordPress (for SMTP)
- WordPress 6.5+: Recommended for
Requires Pluginsheader support
Installation
- Download/upload plugin folder to
/wp-content/plugins/ - Go to Plugins → Installed Plugins
- Find "Registration Notifier for WooCommerce"
- Click Activate
- Configure settings in Settings → Notificação de Registros
File Structure
woocommerce-notificacao-de-registro/
├── woocommerce-notificacao-de-registro.php # Main plugin file
├── src/
│ ├── Plugin.php # Bootstrap class
│ ├── Interfaces/
│ │ └── Hookable.php # Hook interface
│ ├── Admin/
│ │ ├── Settings.php # Settings registration
│ │ ├── SettingsPage.php # Admin page rendering
│ │ └── TestEmail.php # Test email handler
│ ├── Frontend/
│ │ └── RegistrationForm.php # Form fields & validation
│ ├── Email/
│ │ ├── Mailer.php # SMTP & email dispatch
│ │ └── Template.php # HTML email templates
│ └── Utils/
│ ├── Sanitizer.php # Input sanitization
│ └── Validator.php # Field validation
├── includes/
│ └── Migration.php # Settings migration
├── README.md # This file
└── TESTING.md # Testing guide
Architecture
Design Patterns
Hookable Interface Pattern
All components implement Hookable interface to ensure consistent hook registration:
interface Hookable {
public function register_hooks();
}
Dependency Injection Components receive dependencies through constructor and method parameters rather than using globals.
Service Locator
The Plugin class acts as orchestrator, managing all components and their initialization.
Component Breakdown
| Component | Responsibility |
|---|---|
Plugin |
Bootstrap, activation, component orchestration |
Interfaces\Hookable |
Contract for hook-aware components |
Admin\Settings |
Register settings with sanitization callbacks |
Admin\SettingsPage |
Render admin UI, manage settings page |
Admin\TestEmail |
Handle test email form submission |
Frontend\RegistrationForm |
Registration form fields, validation, user data storage |
Email\Mailer |
Send emails via SMTP or wp_mail fallback |
Email\Template |
Generate HTML email templates |
Utils\Sanitizer |
Centralized input sanitization |
Utils\Validator |
Field validation rules |
Migration |
Old → new settings format conversion |
Configuration
Settings Page
Navigate to Settings → Notificação de Registros
Email Configuration:
- E-mail de Notificação: Email address that receives registration notifications
- E-mail do Remetente: Sender email address (appears in "From" field)
- Nome do Remetente: Sender name (appears in "From" field)
SMTP Configuration:
- Servidor SMTP: SMTP server address (e.g., smtp.gmail.com)
- Porta SMTP: SMTP port (usually 587 for TLS, 465 for SSL)
- Encriptação: Encryption type (TLS, SSL, or None)
- Usuário SMTP: SMTP authentication username
- Senha SMTP: SMTP authentication password
Notes:
- If SMTP is not configured, plugin falls back to WordPress default mail
- Leave SMTP fields empty to use WordPress built-in mail function
- Test email feature helps verify SMTP configuration
Security
WPCS Compliance
The plugin follows all WordPress Coding Standards:
- ✅ Input Sanitization: All
$_POST/$_GETdata sanitized before use - ✅ Output Escaping: All output escaped based on context (HTML, attribute, URL)
- ✅ Nonce Verification: CSRF protection on all form submissions
- ✅ Capability Checks: Admin operations verify
manage_optionscapability - ✅ Proper Namespacing: Classes use
WC_Reg_Notifier\namespace to avoid conflicts - ✅ Error Handling: Graceful degradation and logging for failures
Sanitization Examples
// Phone validation/sanitization
$phone = Sanitizer::sanitize_phone($_POST['phone']);
// Email sanitization
$email = Sanitizer::sanitize_email_field($_POST['email']);
// SMTP settings sanitization
$settings = Sanitizer::sanitize_settings($_POST['wc_reg_notifier_settings']);
Nonce Protection
Test email form includes nonce verification:
wp_nonce_field('wc_reg_notifier_test_email', 'wc_reg_notifier_nonce');
Hooks & Filters
WordPress Hooks Used
Actions:
woocommerce_register_form- Add custom fields to registration formwoocommerce_register_post- Validate registration fieldswoocommerce_created_customer- Process registration and send emailadmin_menu- Register settings pageadmin_init- Register settings fieldsadmin_post_wc_reg_notifier_test_email- Handle test email submission
Filters:
plugin_action_links_*- Add settings link to plugin action row
Custom Hooks
None added (user request: WPCS compliance only)
Backwards Compatibility
Settings Migration
When plugin is activated (v4.0.0), migration automatically runs:
- Checks if old settings exist
- Converts to new array format
- Preserves all values
- Sets migration flag
No manual action required. Existing installations upgrade seamlessly.
Internationalization
All user-facing strings use WordPress i18n functions:
__()- Generic translationesc_html__()- Escaped HTML translation_e()- Echo translationesc_html_e()- Echo escaped HTML translation
Text Domain: woocommerce-notificacao-de-registro
To create translations:
- Extract strings:
wp-cli i18n make-pot . - Create
.pofiles from.pot - Place in
/languages/folder
Troubleshooting
Plugin won't activate
- Check PHP version (require 7.4+)
- Verify WooCommerce is active
- Check error log:
wp-content/debug.log
Emails not sending
- Verify SMTP settings are correct
- Check WordPress mail logs
- Enable debug mode:
define('WP_DEBUG', true); - Try test email function on settings page
Settings not saving
- Check file permissions on
/wp-content/ - Verify database user has UPDATE privileges
- Check for PHP errors in debug log
Fields not appearing on registration form
- Verify WooCommerce is active
- Check plugin is activated
- Verify WooCommerce registration page exists
- Try clearing WordPress cache
Development
Code Standards
All code follows WordPress Coding Standards. To check:
phpcs --standard=WordPress src/ includes/ woocommerce-notificacao-de-registro.php
Adding New Features
- Create new class in appropriate namespace
- Implement
Hookableinterface if using hooks - Add unit tests (future enhancement)
- Run WPCS check
- Update documentation
Testing
See TESTING.md for comprehensive testing guide.
Changelog
Version 5.0.0 (Current)
- ✅ readme.txt no formato WordPress.org
- ✅ load_plugin_textdomain() para carregar traduções
- ✅ Arquivo .pot para traduções
- ✅ uninstall.php para limpeza ao desinstalar
- ✅ Verificação de dependência do WooCommerce
- ✅ ABSPATH check em todos os arquivos PHP
- ✅ SMTP password armazenado com base64
- ✅ Campo de senha SMTP não pré-preenche o valor salvo
- ✅ Substituído error_log() por trigger_error()
- ✅ Corrigido basename hardcoded nos links de ação do plugin
- ✅ Internacionalizada string "Acesso negado!" no arquivo principal
- ✅ Nome do plugin alterado para "Registration Notifier for WooCommerce"
Version 4.0.0
- ✅ Complete OOP refactor with proper namespacing
- ✅ Full WPCS compliance and security hardening
- ✅ Nonce verification on all forms
- ✅ Proper sanitization and escaping throughout
- ✅ Enhanced error handling and logging
- ✅ Full PHPDoc documentation
- ✅ Backwards compatibility with automatic settings migration
Version 3.1 (Legacy)
- Basic procedural implementation
- Minimal security features
Support & Issues
For issues or feature requests, please refer to the original repository.
License
GPL v2 or later - See LICENSE file in plugin directory
Author
Gabriel Pacheco
Credits
- WordPress Plugin Security Standards
- PHPMailer for SMTP functionality
- WooCommerce community
Last Updated: May 12, 2026
Plugin Version: 5.0.0
WPCS Status: ✅ Compliant