Created
January 27, 2025 12:31
-
-
Save JarrydLong/71b21c09e1f6aabc36b012e5091202b4 to your computer and use it in GitHub Desktop.
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
<?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