Skip to content

Instantly share code, notes, and snippets.

View cgi-caesar's full-sized avatar

Andrey Yerokhin cgi-caesar

View GitHub Profile
@cgi-caesar
cgi-caesar / site.php
Created March 27, 2020 09:54
aMember (site.php): Show qty within Active Subscriptions widget
<?php
Am_Di::getInstance()->blocks->add('member/main/bottom', new Am_Block_Base(null, 'item-qty', null, function(Am_View $v) {
$di = Am_Di::getInstance();
$user = $di->user;
$_ = $user->getActiveProductIds();
$out = [];
foreach ($_ as $pid) {
$qty = $di->db->selectCell(<<<CUT
SELECT SUM(qty)
@cgi-caesar
cgi-caesar / site.php
Last active March 6, 2020 09:43
aMember (site.php): Profile form as brick for Signup form
<?php
/**
* @title Add All Profile Forms as Available bricks for Signup Forms
*
* If you have aMember version 6.1.7 or below then it is necessary to apply diff (x.diff)
* to file library/Am/Model/SavedForm.php in order to this code snippet work
* @path application/configs/site.php
*/
@cgi-caesar
cgi-caesar / site.php
Created February 18, 2020 17:01
aMember (site.php): Show expiration date for future access periods in Active Subscription Widget
<?php
Am_Di::getInstance()->blocks->add('member/main/bottom', new Am_Block_Base(null, 'future-dates', null, function(Am_View $v) {
$user = Am_Di::getInstance()->user;
$_ = $user->getFutureProductsBeginning();
$out = [];
foreach ($_ as $pid => $begin) {
$period = json_encode($user->getExpire($pid) == Am_Period::MAX_SQL_DATE ?
sprintf("begins %s", amDate($begin)) :
sprintf("%s&ndash;%s", amDate($begin), amDate($user->getExpire($pid))));
@cgi-caesar
cgi-caesar / site.php
Created February 10, 2020 08:22
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
*/
@cgi-caesar
cgi-caesar / site.php
Last active February 10, 2020 08:58
aMember (site.php): Restrict access to avatar image (only admin and owner can see it)
<?php
Am_Di::getInstance()->front->registerPlugin(new class extends Zend_Controller_Plugin_Abstract {
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
if ($request->getModuleName() == 'default' &&
$request->getControllerName() == 'direct' &&
$request->getParam('plugin_id') == 'avatar') {
if (Am_Di::getInstance()->authAdmin->getUser()) {
@cgi-caesar
cgi-caesar / admin-widget-user-product.php
Last active January 31, 2020 08:39
aMember Plugin: Admin Widget Users of Product
<?php
/**
* @title Admin Widget Users of Product
* @desc widget display list of recent users of product
* @path application/default/plugins/misc/admin-widget-user-product.php
*/
class Am_Plugin_AdminWidgetUserProduct extends Am_Plugin
{
@cgi-caesar
cgi-caesar / site.php
Created January 29, 2020 10:24
aMember (site.php): enable admin theme
<?php
Am_Di::getInstance()->viewPath = array_merge(
Am_Di::getInstance()->viewPath,
[APPLICATION_PATH . '/default/themes-admin/yourtheme']
);
$view = Am_Di::getInstance()->view;
$css = $view->_scriptCss('theme.css');
$view->placeholder('head-finish-admin')->append(<<<CUT
<link href="{$css}" media="screen" rel="stylesheet" type="text/css" >
@cgi-caesar
cgi-caesar / aff-payout-paypalssn.php
Created January 29, 2020 10:19
aMember Plugin: PayPal with SSN payout method
<?php
/**
* @title PayPal Payout with SSN
* @desc add new payout method
* @path application/default/plugins/misc/aff-payout-paypalssn.php
*/
class Am_Plugin_AffPayoutPaypalssn extends Am_Plugin
{
const PLUGIN_STATUS = self::STATUS_BETA;
@cgi-caesar
cgi-caesar / site.php
Created January 28, 2020 14:32
aMember (site.php): Add popup window to Thank you page
<?php
Am_Di::getInstance()->blocks->add('thanks/success', new Am_Block_Base(null, 'thanks-popup', null, function (Am_View $v) {
/* @var Invoice $invoice */
$invoice = $v->invoice;
/* @var User $user */
$user = $invoice->getUser();
return <<<CUT
<div id="thanks-popup">Any Content within Popup</div>
@cgi-caesar
cgi-caesar / site.php
Created January 28, 2020 13:06
aMember (site.php): Sync aMember User information to Xenforo 2 custom fields
<?php
/**
* You need to create custom user field within Xenforo admin interface
* Users -> Custom user Fields
*
* Then you can use the following code to sync some data from aMember to Xenforo fields
*
* Then you can use the following syntax within Xenforo template to display this information:
*