Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JarrydLong/71b21c09e1f6aabc36b012e5091202b4 to your computer and use it in GitHub Desktop.
Save JarrydLong/71b21c09e1f6aabc36b012e5091202b4 to your computer and use it in GitHub Desktop.
<?php //do not copy
/**
* This recipe gets the expiration date for a member's membership when updating it from the Edit Member page
*
* 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 mypmpro_get_expiration_date_on_level_save() {
if( ! empty( $_REQUEST['pmpro_member_edit_panel'] ) && $_REQUEST['pmpro_member_edit_panel'] == 'memberships' ){
if( ! empty( $_REQUEST['expires'] ) && (int)$_REQUEST['expires'] ) {
$user_id = (int)$_REQUEST['user_id'];
//We may want to turn this into a timestamp or sanitize
$expiration_date = $_REQUEST['expiration'];
/**
* Do something with $expiraion_date here
*/
}
}
}
add_action( 'admin_init', 'mypmpro_get_expiration_date_on_level_save' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment