Created
February 10, 2020 08:22
-
-
Save cgi-caesar/3875fa07665b03c84c75562b520b65f8 to your computer and use it in GitHub Desktop.
aMember (site.php): User can choose access start date during signup
This file contains hidden or 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 | |
/** | |
* @title User can choose access start date during signup | |
* | |
* Add new Product option with type Date and Label "Start Date" | |
* http://www.amember.com/docs/Product_Options | |
* then put the following code to | |
* @path application/configs/site.php | |
*/ | |
Am_Di::getInstance()->hook->add(Am_Event::CALCULATE_START_DATE, function(Am_Event $e) { | |
if ($e->getIsFirst()) { | |
/** @var InvoiceItem $item */ | |
$item = $e->getItem(); | |
foreach($item->getOptions() as $key => $opt) { | |
if ( | |
$key == 'Start Date' | |
&& !empty($opt['value']) | |
) { | |
$e->setReturn($opt['value']); | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment