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 November 21, 2019 15:54
aMember (site.php): Sync user comment field to user notes
<?php
Am_Di::getInstance()->hook->add(Am_Event::USER_AFTER_UPDATE, function(Am_Event_UserAfterUpdate $e) {
$user = $e->getUser();
$old = $e->getOldUser();
if ($user->comment && $user->comment != $old->comment) {
$note = $e->getDi()->userNoteRecord;
$note->user_id = $user->pk();
$note->content = $user->comment;
@cgi-caesar
cgi-caesar / site.php
Last active April 5, 2021 08:48
aMember (site.php): disallow signups with same first and last name (usually spam signups)
<?php
Am_Di::getInstance()->hook->add(Am_Event::VALIDATE_SAVED_FORM, function (Am_Event_ValidateSavedForm $event) {
$form = $event->getForm();
$vars = $form->getValue();
if (isset($vars['name_f']) && isset($vars['name_l']) && $vars['name_f'] == $vars['name_l'])
{
$event->addError('Some Error Occurred! Please try to signup later...');
}
});
@cgi-caesar
cgi-caesar / site.php
Last active December 17, 2019 10:51
aMember (site.php): add Open Graph Meta to Product Page
<?php
Am_Di::getInstance()->blocks->add('cart/product/title', new Am_Block_Base(null, 'ogp-me', null, function(Am_View $v) {
if ($v->displayProductDetails) {
/** @var Product $product */
$product = $v->product;
$product_url = $product->path ?
$v->surl('product/' . urlencode($product->path), false) :
@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:
*
@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 / 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 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 / 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
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 / 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
*/