Make it mandatory for new users to agree to terms and conditions before signing up

I got a question from an AppGini user on how to make it a requirement for users to check an ‘I agree’ box when they sign up to AppGini — possibly as part of GDPR compliance, or to agree to some other terms and conditions.

We do plan to add support for this as part of future versions of AppGini. However, for now it can be done through a quick JavaScript code customization in hooks/footer-extras.php. The steps in brief are: check if the current page is the signup page, and if so, change custom field #4 to a checkbox, and prevent form submission if the box is unchecked.

The steps above make use of one of the custom user fields and turn it into a checkbox. In AppGini, the user profile supports storing up to 4 customizable fields. If you follow the steps here, one of them will be used for the checkbox, so you’ll have only 3 left. It’s a caveat but can be used as a work-around for now till we implement it as a separate feature in AppGini. So, the code to be placed in hooks/footer-extras.php would look like this:

You could change the wording of the checkbox by editing line 12 above. Also, you could change the error message by changing line 17. You’ll need to add a file containing the terms and conditions in the hooks folder, naming it terms.php. It might look something like this:

Change the wording above as you see fit. Please let me know if you have any questions or comments.

Published by Genedy

I'm the founder of BigProf Software. We're a tiny team of developers who create tools that make it easy (and affordable) for anyone to create connected business applications that work from any device with a browser.

9 replies on “Make it mandatory for new users to agree to terms and conditions before signing up”

  1. Hi Ahmed,
    I made the changes as shown, all works as intended except:
    Once a new signup selects checkbox (on a group marked as automatically approve them) the app jumps to myurldirectory /admin/membership_thankyou.php?redir=1
    instead of myurldirectory /membership_thankyou.php?redir=1

    Cheers,

    1. I’ve received some similar reports recently and I’m investigating it .. Is your AppGini app hosted on the document root directly? For example, on example.com directly rather than example.com/app?

      1. Thanks for quick reply. Yes its directly mysite.com
        Maybe nothing to do with it, but only real difference to my AG setup is I took out line as follows:
        $dbServer = ‘db00000000.hosting-data.io’;
        $dbUsername = ‘dbu00000000’;
        $dbPassword = ‘00000000’;
        $dbDatabase = ‘dbs00000000’;
        // $appURI = ‘OCMS’;

        1. I assume the above are not actual username/password for your database as this is a public comment 🙂
          Please try changing the commented line (after uncommenting it) to:
          $appURI = '';

  2. Hi Ahmed,
    Sorry, just did a test on local PC where I leave in reference to
    $appURI = ‘OCMS’; and it takes me to correct page, so it does seem to be related to this. Unfortunately online/server only works on my projects when I take out the $appURI line in config file, if left in it takes me to blank page.

    1. As I suggested above, try changing that to:
      $appURI = '';
      When moving your AppGini app from localhost or testing environment to production server, you should not upload config.php as this would differ between the 2 servers. Once uploaded, you should then see the setup page and perform the setup according to the server settings.

      1. Understood, I normally do it that way. However, sometimes I prepare the database locally inclusive groups, users, example records etc. and export/upload the entire sql to my server host with a revised config.php – So it was my error in config file. Thanks for sorting this out for me, much appreciated.

Comments are closed.