How to make a checkbox mandatory in AppGini signup form
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.
Archived Comments
Ron Williams
2019-05-07 at 1:27 pm
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,
Genedy
2019-05-07 at 3:10 pm
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 thanexample.com/app
?
Ron Williams
2019-05-07 at 5:38 pm
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:
1 2 3 4 5
$dbServer = ‘db00000000.hosting-data.io’; $dbUsername = ‘dbu00000000’; $dbPassword = ‘00000000’; $dbDatabase = ‘dbs00000000’; // $appURI = ‘OCMS’;
Genedy
2019-05-07 at 11:43 pm
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:
1
$appURI = '';
Ron Williams
2019-05-08 at 12:02 am
Perfect, works a treat.
LOL no not actual user/password.
Thanks Ahmed
Ron Williams
2019-05-07 at 5:46 pm
Hi Ahmed,
Sorry, just did a test on local PC where I leave in reference to
1
$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.
Genedy
2019-05-07 at 11:52 pm
As I suggested above, try changing that to:
1
$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.
Ron Williams
2019-05-08 at 1:15 pm
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.
Genedy
2019-05-08 at 2:32 pm
You’re always welcome 🙂 I’m glad it works now.