The Member Class
Member creation and manipulation
Functions
Member::addNewMembership
Definition
- Name
- addNewMembership
- Syntax
- Array|False = Member::addNewMembership( Array $action );
Description
Add new membership to current user.
Can be called via API, as opposed to Member::addMembership.
/#controller#/addNewMembership/
Parameters
- $action
-
Array Action array.
Action parameters
Parameters in $_POST
Return values
Array|false Order object. False on error.
Examples
$MC = new Member();
$_POST["item_id"] = $item_id;
$order = $MC->addNewMembership($action);
Dependencies
PHP
- count
- unset
Janitor
- Model::getPostedEntities
- Model::validateList
- Model::getProperty
- User::getUser
- Shop::addToNewInternalCart
- Shop::newOrderFromCart
Member::addMembership
Definition
- Name
- addMembership
- Syntax
- Array|False = Member::addMembership( Integer $item_id, Integer $subscription_id, Array|false $_options );
Description
Add membership to current user.
Meant for internal use, as opposed to Member::addNewMembership.
Parameters
- $item_id
-
Integer Id for membership item.
- $subscription_id
-
Integer Id for subscription.
- $_options
-
Array|false Not in use. Exists to maintain compatibility with SuperMember::addMembership.
Return values
Array|false Membership object. False on error.
Examples
$MC = new Member();
$membership = $MC->addMembership($item_id, $subscription_id);
Dependencies
Janitor
- Member::getMembership
- Query::sql
- Page::addLog
Member::getMembership
Definition
- Name
- getMembership
- Syntax
- Array|False = Member::getMembership();
Description
Get membership for current user.
Includes membership item and order.
Return values
Array|false Membership object. False on error.
Examples
$MC = new Member();
$membership = $MC->getMembership();
Dependencies
Janitor
- session()->value
- Query::sql
- Query::result
- Items::getItems
- Shop::getOrders
Member::updateMembership
Definition
- Name
- updateMembership
- Syntax
- Array|False = Member::updateMembership( Array $options = false );
Description
Update membership for current user.
Parameters
- $_options
-
Array|False Optional parameters.
Options
Return values
Array|false Membership object. False on non-existing membership. False on error.
Examples
Normal use:
$MC = new Member();
$membership = $MC->updateMembership();
Reactivating an inactive (cancelled) membership:
$MC = new Member();
$membership = $MC->updateMembership(["subscription_id" => $subscription_id]);
Dependencies
Janitor
- session()->value()
- Subscription::getSubscriptions
- Member::getMembership
- Query::sql
- Page::addLog
Member::cancelMembership
Definition
- Name
- cancelMembership
- Syntax
- Boolean = Member::cancelMembership( Array $action );
Description
Cancel membership of current user.
Removes subscription_id from membership and deletes related subscription. Sends a notification email to administrator.
/#controller#/cancelMembership/#member_id#
Parameters
- $action
-
Array Action array.
Action parameters
Return values
Boolean True on successful cancellation. False on error.
Examples
$MC = new Member();
$order = $MC->cancelMembership($action);
Dependencies
PHP
- count
Janitor
- session()->value()
- Member::getMembership
- Subscription::deleteSubscription
- Page::addLog
- mailer()->send()
Member::upgradeMembership
Definition
- Name
- upgradeMembership
- Syntax
- Boolean = Member::upgradeMembership( Array $action );
Description
Upgrade membership for current user.
Adds new order with custom price (new_price - current_price). Gets existing membership order and copies info to new membership order, then adds manual order line.
/#controller#/upgradeMembership/
Parameters
- $action
-
Array Action array.
Action parameters
Parameters in $_POST
Return values
Boolean True on successful upgrade. False on error.
Examples
$MC = new Member();
$_POST["item_id"] = $item_id;
$upgrade_success = $MC->upgradeMembership($action);
Dependencies
PHP
- count
- preg_match
Janitor
- Model::getProperty
- Member::getMembership
- Shop::getPrice
- Shop::getNewOrderNumber
- Shop::getOrders
- Subscription::getSubscriptions
- Subscription::calculateSubscriptionExpiry
- Items::getItem
- Items::typeObject
- Query::sql
- Query::result
- Page::addLog
Member::switchMembership
Definition
- Name
- switchMembership
- Syntax
- Array|False = Member::switchMembership( Array $action );
Description
Switch membership for current user.
/#controller#/switchMembership/
Parameters
- $action
-
Array Action array.
Action parameters
Parameters in $_POST
Return values
Array|false Order object. False on error.
Examples
$MC = new Member();
$_POST["item_id"] = $item_id;
$order = $MC->switchMembership($action);
Dependencies
PHP
- count
Janitor
- session()->value()
- Model::getPostedEntities
- Model::validateList
- Model::getProperty
- Member::getMembership
- Shop::addToNewInternalCart
- Shop::newOrderFromCart