Download aMember Pro
Transcript
Customization
8.6.1
64
Hooks - validation functions
validate_signup_form(&$vars)
This function will be called when user submits signup form. $vars is an array of
submitted values. You may check it and return array of errors. If no errors found, you may
return empty array.
This function is extremelly useful, when you added some fields and need to validate
entered values for these fields. This function can also change submitted variables
(validation goes before any processing).
Example (validates additional phone and fax fields ):
function vsf(&$vars){
$errors = array();
if (!strlen($vars['phone'])
$errors[] = "Please enter phone number;
if (!strlen($vars['fax'])
$errors[] = "Please enter fax number;
}
setup_plugin_hook('validate_signup_form', 'vsf');
validate_member_form(&$vars)
This function will be called when user submits renewal form from
http://www.yoursite.com/amember/member.php. $vars is an array of submitted values.
You may check it and return array of errors. If no errors found, you may return empty
array. Please note, that this form doesn't contain any member info. However, you may get
member info from session.
8.6.2
Hooks - payments update
finish_waiting_payment($payment_id)
This function called when payment(subscription) status changes to Paid ("Completed").
Then you can retreive info from database about payment and use it to execute some
actions.
Please note - if admin switches payment status Paid -> NotPaid -> Paid from control
panel, this function can be executed twice for the same payment. Be careful.
Example of this hook function:
function fwp($payment_id){
global $db;
$payment = $db->get_payment($payment_id); // $payment is now
array
$product = $db->get_product($payment['product_id']);
$member = $db->get_user($payment['member_id']);
print "For this period: $payment[begin_date] $payment[expire_date]<br>";
print "$product[title] ordered by $member[name_f]
$member[name_l]<br>";
}
update_payments($payment_id)
This function called when payment $payment_id has been updated somehow - changed,
© 2002-2006, CGI-Central