public get_joined_date ( $subscription_id ) : string | ||
Résultat | string | Joined date |
public function get_joined_date($subscription_id = 0)
{
if (empty($subscription_id)) {
$subscription_id = $this->get_subscription_id();
}
$date = get_user_meta($this->ID, 'rcp_joined_date_' . $subscription_id, true);
// Joined dates were not stored until RCP 2.6. For older accounts, look up first payment record.
if (empty($date)) {
$sub_name = rcp_get_subscription_name($subscription_id);
$args = array('user_id' => $this->ID, 'subscription' => $sub_name, 'order' => 'ASC', 'number' => 1);
$payments = new RCP_Payments();
$payments = $payments->get_payments($args);
if ($payments) {
$payment = reset($payments);
$date = $payment->date;
$this->set_joined_date($date, $subscription_id);
}
}
return apply_filters('rcp_get_joined_date', $date, $this->ID, $subscription_id, $this);
}
/** * Prevents the "Cancel your subscription" link from showing * until the member has been subscribed to his or her current * subscription for 3 months. */ function jp_rcp_member_can_cancel($ret, $user_id) { global $rcp_options; // Only do this on the Account Page if (empty($rcp_options['account_page']) || !is_page($rcp_options['account_page'])) { return $ret; } // Return early if other conditions aren't already met. if (!$ret) { return false; } $timezone = get_option('timezone_string'); $timezone = !empty($timezone) ? $timezone : 'UTC'; $member = new RCP_Member($user_id); $cancel_date = new \DateTime($member->get_joined_date(), new \DateTimeZone($timezone)); $cancel_date->modify('+3 months'); // change this if you want a different time period $now = new \DateTime('now', new \DateTimeZone($timezone)); if ($ret && $now < $cancel_date) { $ret = false; } return $ret; }