Skip to content

Instantly share code, notes, and snippets.

@cgi-caesar
Created February 10, 2020 08:22
Show Gist options
  • Save cgi-caesar/3875fa07665b03c84c75562b520b65f8 to your computer and use it in GitHub Desktop.
Save cgi-caesar/3875fa07665b03c84c75562b520b65f8 to your computer and use it in GitHub Desktop.
aMember (site.php): User can choose access start date during signup
<?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