Skip to content

Instantly share code, notes, and snippets.

@kimwhite
Created September 9, 2024 18:06
Show Gist options
  • Save kimwhite/9e0368116c691fa441a2a999899fce62 to your computer and use it in GitHub Desktop.
Save kimwhite/9e0368116c691fa441a2a999899fce62 to your computer and use it in GitHub Desktop.
This recipe creates an email variable for the current date.
<?
/**
* This recipe creates an email variable for the current date.
* !!current_date!! will show the current date in the confirmation email.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_email_variable_current_date( $data, $email ) {
// Get the current date based on WordPress settings
$current_date = current_time('mysql'); // Format is 'Y-m-d H:i:s' by default
// Add the current date to the email data
$data['current_date'] = date(get_option( 'date_format' ), strtotime($current_date));
return $data;
}
add_filter( 'pmpro_email_data', 'my_pmpro_email_variable_current_date', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment