Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andrewlimaza/34d6a85eeff465f7d28f876d9ed20409 to your computer and use it in GitHub Desktop.
Save andrewlimaza/34d6a85eeff465f7d28f876d9ed20409 to your computer and use it in GitHub Desktop.
Edit Email Data for PMPro Signup Shortcode
<?php
/**
* Edit the Signup Shortcode password that is generated and emailed to the customer.
* Add this code to your site by following this guide: https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
remove_filter('pmpro_email_data', 'pmprosus_pmpro_email_data', 10, 2);
function pmprosus_pmpro_email_data_edit($data, $email) {
if ( function_exists( 'pmpro_start_session' ) ) {
pmpro_start_session();
}
// Include the generated password in the confirmation email.
if ( ! empty( $_SESSION['pmprosus_autogenerated_password'] ) && strpos( $email->template, 'checkout_' ) !== false ) {
$data['user_email'] = sprintf(__('Email: %s<br/> Password: %s', 'pmprosus'), $data['user_email'], $_SESSION['pmprosus_autogenerated_password'] );
// Clear session variable
unset( $_SESSION['pmprosus_autogenerated_password'] );
}
return $data;
}
add_filter('pmpro_email_data', 'pmprosus_pmpro_email_data_edit', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment