This question has been answered by BobRay. See the first response.
$expDate = $modx->user->get('remote_key');
You might consider using the User Profile's DOB (date of birth) field for the expiration date if you're not already using it. It would be faster and easier than an extended field.
Even faster, would be to use the remote_key field of the modUser object. It's a string field, so you could store either a human-readable date or a unix timestamp there. Since $modx->user is always available for logged-in users, this would get it in your snippet:
$expDate = $modx->user->get('remote_key');
if (!$modx->user->isAuthenticated('web')) { $startdate = "16-May-2016"; $expire = strtotime($startdate. ' + 2 days'); $today = strtotime("today midnight"); if($today >= $expire){ // Show message: Membership not valid }else { // Show video } }else { // Show messge: login }
It looks good to me, though you might want to add another section for when it's close to running out, warning the user that their subscription will lapse in x days and suggesting that they "click here" to re-up.
You might consider using the User Profile's DOB (date of birth) field for the expiration date if you're not already using it. It would be faster and easier than an extended field.
Even faster, would be to use the remote_key field of the modUser object. It's a string field, so you could store either a human-readable date or a unix timestamp there. Since $modx->user is always available for logged-in users, this would get it in your snippet:
$expDate = $modx->user->get('remote_key');
$expDate = $modx->user->set('remote_key', '10-10-2016');
$modx->user->save();
$usr = $modx->getObject('modUser', $modx->user->get('id')); $usr->set('remote_key', '10-10-2016'); $usr->save();