Created
September 9, 2024 18:06
-
-
Save kimwhite/9e0368116c691fa441a2a999899fce62 to your computer and use it in GitHub Desktop.
This recipe creates an email variable for the current date.
This file contains hidden or 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
<? | |
/** | |
* 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