[ENHANCEMENT] ADD V3.4+ Email Template Approach#56
Conversation
* Create a new class in the hierarchy of the PMPro_Email_Template class * Require the child class if Parent class exists. Add filter to old template otherwise * Call new class if we're in the class exists
|
Made this one a draft @dparker1005 because of these doubts.
|
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the email confirmation system to support the new PMPro Email Template framework while maintaining backward compatibility with the legacy email system. It conditionally loads the appropriate email handling based on whether the PMPro_Email_Template class exists.
Key changes:
- Introduces a new
PMPro_Email_Template_Resend_Confirmationclass for modern email template handling - Modifies the plugin initialization to conditionally include the new email template class or register the legacy template filter
- Updates
pmproec_resend_confirmation_email()to handle both new and legacy email systems with proper success message handling
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| pmpro-email-confirmation.php | Adds conditional logic to support both new PMPro Email Template system and legacy email system, updates plugin initialization hook priority, and improves success message handling |
| classes/email-templates/class-pmpro-email-template-pmpro-email-confirmation-resend-confirmation.php | New email template class extending PMPro_Email_Template for handling resend confirmation emails in the modern framework |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| class PMPro_Email_Template_Resend_Confirmation extends PMPro_Email_Template { | ||
|
|
||
| /** | ||
| * The parent user. |
There was a problem hiding this comment.
The comment 'The parent user' is unclear. This should be 'The user receiving the confirmation email' or simply 'The user' to better describe the property's purpose.
| * The parent user. | |
| * The user receiving the confirmation email. |
| * | ||
| * @since TBD | ||
| * | ||
| * @param WP_User $user The user will receive the email. |
There was a problem hiding this comment.
Corrected grammar from 'The user will receive' to 'The user who will receive' for better readability.
| * @param WP_User $user The user will receive the email. | |
| * @param WP_User $user The user who will receive the email. |
| // '!!display_name!!' => esc_html__( 'The display name of the user need to confirm the email', 'pmpro-email-confirmation' ), | ||
| // '!!user_login!!' => esc_html__( 'The login name of the user need to confirm the email', 'pmpro-email-confirmation' ), | ||
| // '!!user_email!!' => esc_html__( 'The email address of the user need to confirm the email', 'pmpro-email-confirmation' ), |
There was a problem hiding this comment.
These commented-out template variables are defined in get_email_template_variables() (lines 114-116) but not exposed in get_email_template_variables_with_description(). If these variables are not intended to be available for use in email templates, they should be removed from the method. If they should be available, uncomment and fix the grammar ('user need' should be 'user who needs').
| // '!!display_name!!' => esc_html__( 'The display name of the user need to confirm the email', 'pmpro-email-confirmation' ), | |
| // '!!user_login!!' => esc_html__( 'The login name of the user need to confirm the email', 'pmpro-email-confirmation' ), | |
| // '!!user_email!!' => esc_html__( 'The email address of the user need to confirm the email', 'pmpro-email-confirmation' ), | |
| '!!display_name!!' => esc_html__( 'The display name of the user who needs to confirm the email.', 'pmpro-email-confirmation' ), | |
| '!!user_login!!' => esc_html__( 'The login name of the user who needs to confirm the email.', 'pmpro-email-confirmation' ), | |
| '!!user_email!!' => esc_html__( 'The email address of the user who needs to confirm the email.', 'pmpro-email-confirmation' ), |
| * @return string The name of the email recipient. | ||
| */ | ||
| public function get_recipient_name() { | ||
|
|
There was a problem hiding this comment.
Remove the empty line with trailing whitespace before the return statement.
| $body = str_ireplace( "!!validation_link!!", $url, $body ); | ||
| if ( class_exists( 'PMPro_Email_Template' ) ) { | ||
| $send_resend_confirmation_email = new PMPro_Email_Template_Resend_Confirmation( $user, $url ); | ||
| $mail_sent_successfully = $send_resend_confirmation_email->send(); |
There was a problem hiding this comment.
When using the new PMPro_Email_Template system (lines 431-433), the success message is never set. The $pmproec_msg and $pmproec_msgt globals are only set within the else block (lines 465-468). This means users won't see a confirmation message when the email is sent using the new template system. Add the success message logic after line 433.
| $mail_sent_successfully = $send_resend_confirmation_email->send(); | |
| $mail_sent_successfully = $send_resend_confirmation_email->send(); | |
| if ( $mail_sent_successfully ) { | |
| $pmproec_msg = esc_html__( 'A confirmation email has been sent to', 'pmpro-email-confirmation' ) . ' ' . $user->user_email; | |
| $pmproec_msgt = 'updated'; | |
| } |
All Submissions:
Changes proposed in this Pull Request:
How to test the changes in this Pull Request:
Other information:
Changelog entry