How to define maximum number of registrations allowed per IP within 24 hours

From aMember Pro Documentation
Revision as of 03:44, 28 October 2015 by Caesar (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Create file /amember/application/configs/site.php with this code:

<?php
Am_Di::getInstance()->hook->add(Am_Event::LOAD_SIGNUP_FORM, function(Am_Event $e) {
    $reg_max = 10;
    $reg_num = $e->getDi()->db->selectCell("SELECT COUNT(*) FROM ?_user WHERE remote_addr = ? AND added>?",
        $_SERVER['REMOTE_ADDR'], sqlTime('- 24 hours'));
    if ($reg_num > $reg_max) {
        throw new Am_Exception_InputError(___('Registration from you IP is temporary disabled'));
    }
});