Did you get any help with this? I have the same issue
Thread Starter
RiaanC
(@riaanc)
Hi. No I did not. Currently I have to manually set the expiry date so it is not truly automated.
If you use the default WP registration form it works just fine.
Do you know if it works with WPForms?
Thread Starter
RiaanC
(@riaanc)
No sorry. I have not tested that.
// Setup Gravity Forms Memberships Hooks
add_action( ‘gform_user_registered’, ‘saf_cc_add_custom_user_meta’, 10, 4 );
function saf_cc_add_custom_user_meta( $user_id, $feed, $entry, $user_pass ) {
$time_period = trim($entry[8]);
if($feed[‘form_id’] != 1) {
return;
}
$user = get_user_by( ‘id’, $user_id );
if(!empty($user)) {
$current_time = current_time(‘timestamp’);
if($time_period == ‘One Day for $15|15’) {
$new_time = ‘+1 day’;
} else if ($time_period == ‘One Week for $30|30’) {
$new_time = ‘+1 week’;
} else if( $time_period == ‘3 Months for $250|250’) {
$new_time = ‘+3 months ‘;
} else if ($time_period == ‘6 Months for $500|500’) {
$new_time = ‘+6 months’;
} else if ($time_period == ‘1 Year for $800|800’) {
$new_time = ‘+1 year’;
} else {
$new_time = ”;
}
$time = strtotime($new_time, $current_time);
$default_settings = array (
‘default_to_role’ => ‘subscriber’,
‘reset_password’ => false,
’email’ => false,
’email_admin’ => false,
‘remove_expiry’ => false,
);
$updated = update_user_meta($user_id, ‘_expire_user_settings’, $default_settings );
$updated = update_user_meta($user_id, ‘_expire_user_date’, $time );
$updated = update_user_meta($user_id, ‘_expire_user_expired’, ‘N’ );
}
}
function my_expire_users_expired( $user ) {
//may be we need it in future
}
add_action( ‘expire_users_expired’, ‘my_expire_users_expired’ );tions here */