Country specific forms

Discussion in 'Customization & add-ons' started by carmelr, Aug 2, 2014.

  1. carmelr

    carmelr New Member

    Joined:
    Mar 5, 2013
    Messages:
    17
    Is there an add-on or built-in function for aMember that displays a form according to the country the IP is from?
    This would be helpful for having different currencies for different countries.

    Thanks
    Carmelo
  2. thehpmc

    thehpmc Member

    Joined:
    Aug 24, 2006
    Messages:
    901
    This should be easy to do using simple PHP script.

    You would need to customise the form, you don't say which form, then call your IP lookup script which would then call up the correct form dependant upon which country IP address is registered to.
  3. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    In order to achieve it you need to have PHP programmer. There is not ability to do it in admin interface but it can be done without changes in core files (as extension). Here is some guide how it can be done in aMember.

    You can use hook Am_Event::LOAD_SIGNUP_FORM to do it. You can read about hooks here
    http://www.amember.com/docs/API/HookManager

    Here is example of code that can be used in site.php (http://www.amember.com/docs/Site.php_file) to implement it
    PHP:
    Am_Di::getInstance()->hook->add(Am_Event::LOAD_SIGNUP_FORM'chooseSignupForm');
     
    function 
    chooseSignupForm(Am_Event $e) {
        if (
    $e->getRequest()->getParam('c')) {
                return; 
    //only for default signup form
        
    }
     
        
    //choose signup form somehow based on IP address
        //for example you may use country code as signup form code
        //and retrieve record with necessary form
        //but first you need to get user country by IP
        //you may use some public IP database to lookup
        //country for specific IP address
        
    $form $e->getDi()->savedFormTable->findFirstBy(array(
            
    'code' => 'signup-US',
            
    'type' => SavedForm::T_SIGNUP,
        ));
     
        if (
    $form) {
            
    //in case of form for this country exits
            //replace default form with form sprcific for country
            
    $e->setReturn($form);
        }
    }
    I hope this info will be useful for you.

    Best Regards.

Share This Page