From bc9211ea7ffabd60b75c99da73ab07599dc67599 Mon Sep 17 00:00:00 2001 From: Andrew Lima Date: Fri, 19 Apr 2024 15:40:48 +0200 Subject: [PATCH 1/3] Added filter to show custom confirmation message. * ENHANCEMENT: Added the filter `pmpro_approvals_show_confirmation_message` which allows you to show the custom levels confirmation message. Defaults to false. --- pmpro-approvals.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pmpro-approvals.php b/pmpro-approvals.php index b4f5957..39bddaf 100644 --- a/pmpro-approvals.php +++ b/pmpro-approvals.php @@ -1387,7 +1387,7 @@ public static function pmpro_membershiplevels_template_level( $level, $template */ public static function pmpro_confirmation_message( $confirmation_message, $pmpro_invoice ) { - global $current_user; + global $current_user, $wpdb; // Try to get the membership ID for the confirmation. if ( ! empty( $pmpro_invoice ) ) { @@ -1421,7 +1421,21 @@ public static function pmpro_confirmation_message( $confirmation_message, $pmpro $confirmation_message .= '
' . wpautop( wp_unslash( get_option("pmpro_instructions") ) ) . '
'; } + /** + * Filter to show the confirmation message for levels that require approval. + * @param bool $show Whether to show the confirmation message or not. + * @param int $membership_id The membership ID for the current view. + * @since TBD + */ + if ( apply_filters( 'pmpro_approvals_show_confirmation_message', false, $pmpro_invoice->membership_id ) ) { + // Add the level confirmation message if set. + $level_message = $wpdb->get_var("SELECT confirmation FROM $wpdb->pmpro_membership_levels WHERE id = '" . intval( $pmpro_invoice->membership_id ) . "' LIMIT 1"); + if ( ! empty( $level_message ) ) { + $confirmation_message .= wpautop( stripslashes( $level_message ) ); + } + } + $confirmation_message .= '

' . sprintf( __( 'Below are details about your membership account and a receipt for your initial membership invoice. A welcome email with a copy of your initial membership invoice has been sent to %s.', 'pmpro-approvals' ), $current_user->user_email ) . '

'; return $confirmation_message; From 6ab9a173790255788961acdc9ca128d4952ca59c Mon Sep 17 00:00:00 2001 From: Andrew Lima Date: Thu, 18 Jul 2024 15:59:43 +0200 Subject: [PATCH 2/3] Renaming the filter. * Rename the filter to be even more clear. --- pmpro-approvals.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmpro-approvals.php b/pmpro-approvals.php index 39bddaf..255f3a0 100644 --- a/pmpro-approvals.php +++ b/pmpro-approvals.php @@ -1427,7 +1427,7 @@ public static function pmpro_confirmation_message( $confirmation_message, $pmpro * @param int $membership_id The membership ID for the current view. * @since TBD */ - if ( apply_filters( 'pmpro_approvals_show_confirmation_message', false, $pmpro_invoice->membership_id ) ) { + if ( apply_filters( 'pmpro_approvals_show_levels_confirmation_message', false, $pmpro_invoice->membership_id ) ) { // Add the level confirmation message if set. $level_message = $wpdb->get_var("SELECT confirmation FROM $wpdb->pmpro_membership_levels WHERE id = '" . intval( $pmpro_invoice->membership_id ) . "' LIMIT 1"); From 87b9eafb2cf872d7b915667322197857f883ffe8 Mon Sep 17 00:00:00 2001 From: Andrew Lima Date: Thu, 18 Jul 2024 16:01:10 +0200 Subject: [PATCH 3/3] Change filter name to level. --- pmpro-approvals.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmpro-approvals.php b/pmpro-approvals.php index 255f3a0..3debc2f 100644 --- a/pmpro-approvals.php +++ b/pmpro-approvals.php @@ -1427,7 +1427,7 @@ public static function pmpro_confirmation_message( $confirmation_message, $pmpro * @param int $membership_id The membership ID for the current view. * @since TBD */ - if ( apply_filters( 'pmpro_approvals_show_levels_confirmation_message', false, $pmpro_invoice->membership_id ) ) { + if ( apply_filters( 'pmpro_approvals_show_level_confirmation_message', false, $pmpro_invoice->membership_id ) ) { // Add the level confirmation message if set. $level_message = $wpdb->get_var("SELECT confirmation FROM $wpdb->pmpro_membership_levels WHERE id = '" . intval( $pmpro_invoice->membership_id ) . "' LIMIT 1");