# s2member/120213/includes/classes/registration-times.inc.php

s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls &amp; Member Access Subscriptions, version 120213. 110 lines.

- Page: https://pluginprobe.com/plugins/s2member/120213/code/includes/classes/registration-times.inc.php
- Raw: https://pluginprobe.com/plugins/s2member/120213/raw/includes/classes/registration-times.inc.php
- Modified: 2012-02-14T02:48:06+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/s2member/120213/code/includes/classes/registration-times.inc.php#L10-L20`.

```php
<?php
/**
* Registration Times.
*
* Copyright: © 2009-2011
* {@link http://www.websharks-inc.com/ WebSharks, Inc.}
* ( coded in the USA )
*
* Released under the terms of the GNU General Public License.
* You should have received a copy of the GNU General Public License,
* along with this software. In the main directory, see: /licensing/
* If not, see: {@link http://www.gnu.org/licenses/}.
*
* @package s2Member\Registrations
* @since 3.5
*/
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
	exit ("Do not access this file directly.");
/**/
if (!class_exists ("c_ws_plugin__s2member_registration_times"))
	{
		/**
		* Registration Times.
		*
		* @package s2Member\Registrations
		* @since 3.5
		*/
		class c_ws_plugin__s2member_registration_times
			{
				/**
				* Synchronizes Paid Registration Times with Role assignments.
				*
				* @package s2Member\Registrations
				* @since 3.5
				*
				* @attaches-to ``add_action("set_user_role");``
				*
				* @param int|str $user_id A numeric WordPress® User ID should be passed in by the Action Hook.
				* @param str $role A WordPress® Role ID/Name should be passed in by the Action Hook.
				* @return null
				*/
				public static function synchronize_paid_reg_times ($user_id = FALSE, $role = FALSE)
					{
						eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
						do_action ("ws_plugin__s2member_before_synchronize_paid_reg_times", get_defined_vars ());
						unset ($__refs, $__v); /* Unset defined __refs, __v. */
						/**/
						if ($user_id && is_object ($user = new WP_User ($user_id)) && !empty ($user->ID) && ($level = c_ws_plugin__s2member_user_access::user_access_level ($user)) > 0)
							{
								$pr_times = get_user_option ("s2member_paid_registration_times", $user_id);
								$pr_times["level"] = (empty ($pr_times["level"])) ? time () : $pr_times["level"];
								$pr_times["level" . $level] = (empty ($pr_times["level" . $level])) ? time () : $pr_times["level" . $level];
								update_user_option ($user_id, "s2member_paid_registration_times", $pr_times); /* Update now. */
							}
						/**/
						return; /* Return for uniformity. */
					}
				/**
				* Retrieves a Registration Time.
				*
				* @package s2Member\Registrations
				* @since 3.5
				*
				* @param int|str $user_id Optional. A numeric WordPress® User ID. Defaults to the current User, if logged-in.
				* @return int A Unix timestamp, indicating Registration Time, else `0` on failure.
				*/
				public static function registration_time ($user_id = FALSE)
					{
						eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
						do_action ("ws_plugin__s2member_before_registration_time", get_defined_vars ());
						unset ($__refs, $__v); /* Unset defined __refs, __v. */
						/**/
						$user = ($user_id) ? new WP_User ($user_id) : ((is_user_logged_in ()) ? wp_get_current_user () : false);
						/**/
						if (is_object ($user) && !empty ($user->ID) && ($user_id = $user->ID) && $user->user_registered)
							{
								return apply_filters ("ws_plugin__s2member_registration_time", strtotime ($user->user_registered), get_defined_vars ());
							}
						else /* Else we return a default value of 0, because there is insufficient data. */
							return apply_filters ("ws_plugin__s2member_registration_time", 0, get_defined_vars ());
					}
				/**
				* Retrieves a Paid Registration Time.
				*
				* @package s2Member\Registrations
				* @since 3.5
				*
				* @param int|str $level Optional. Defaults to the first/initial Paid Registration Time, regardless of Level#.
				* @param int|str $user_id Optional. A numeric WordPress® User ID. Defaults to the current User, if logged-in.
				* @return int A Unix timestamp, indicating Paid Registration Time, else `0` on failure.
				*/
				public static function paid_registration_time ($level = FALSE, $user_id = FALSE)
					{
						eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
						do_action ("ws_plugin__s2member_before_paid_registration_time", get_defined_vars ());
						unset ($__refs, $__v); /* Unset defined __refs, __v. */
						/**/
						$level = (!is_numeric ($level)) ? "level" : "level" . preg_replace ("/[^0-9]/", "", (string)$level);
						$user = ($user_id) ? new WP_User ($user_id) : ((is_user_logged_in ()) ? wp_get_current_user () : false);
						/**/
						if ($level && is_object ($user) && !empty ($user->ID) && ($user_id = $user->ID) && is_array ($pr_times = get_user_option ("s2member_paid_registration_times", $user_id)))
							{
								return apply_filters ("ws_plugin__s2member_paid_registration_time", ((isset ($pr_times[$level])) ? (int)$pr_times[$level] : 0), get_defined_vars ());
							}
						else /* Else we return a default value of `0`, because there is insufficient data. */
							return apply_filters ("ws_plugin__s2member_paid_registration_time", 0, get_defined_vars ());
					}
			}
	}
?>
```
