Created
December 12, 2017 03:05
-
-
Save greathmaster/e222c6fd11a3a077c955d02f56463164 to your computer and use it in GitHub Desktop.
Keep the custom messages set for each level under Membership >> Membership Levels and combine it with the PMPro Approvals status.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function modify_status_from_confirmation_message($confirmation_message, $pmpro_invoice) | |
{ | |
global $current_user, $wpdb; | |
$approval_status = null; | |
if(class_exists('PMPro_Approvals')) | |
$approval_status = PMPro_Approvals::getUserApprovalStatus(); | |
if(!empty($approval_status)) | |
{ | |
$confirmation_message = "<p>" . sprintf(__('Thank you for your membership to %s. Your %s membership status is: <b>%s</b>.', 'pmpro-approvals' ), get_bloginfo("name"), $current_user->membership_level->name, $approval_status) . "</p>"; | |
} | |
$level_message = $wpdb->get_var("SELECT l.confirmation FROM $wpdb->pmpro_membership_levels l LEFT JOIN $wpdb->pmpro_memberships_users mu ON l.id = mu.membership_id WHERE mu.status = 'active' AND mu.user_id = '" . $current_user->ID . "' LIMIT 1"); | |
if(!empty($level_message)) | |
$confirmation_message .= "\n" . stripslashes($level_message) . "\n"; | |
$confirmation_message .= "<p>" .__('Below are details about your membership account:'); | |
return $confirmation_message; | |
} | |
add_filter( 'pmpro_confirmation_message', 'modify_status_from_confirmation_message', 10, 2); | |
function my_init() | |
{ | |
remove_filter( 'pmpro_confirmation_message', array( 'PMPro_Approvals', 'pmpro_confirmation_message' ) ); | |
} | |
add_action('init', 'my_init'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment