Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
2.6k views
in Q2A Core by
Hi @ all.

I try to customize the user registration form. In germany we have so much laws an i need to integrate a checkbox, which uers have to check before they can sucessfull registrate on the site.

Something like 'I read the terms of use' and only if checked=checked then the form will be send.

Perhaps someone can give me a hint or a code-snipet, where and what to insert in the qa-page-register.php

th@nx, Mani

2 Answers

+2 votes
by
Okay, i worked step by step, but now, i dont know, how to ask for the $errors

$errors=array_merge(
            qa_handle_email_validate($inhandle, $inemail),
            qa_password_validate($inpassword)
        );

with qa_handle_email_, i validate the $inhandle, and the $inemail,

with qa_password_, i validate the $inpassword but how can i check, if checkbox is not checked. for this case i need the $error message ond the form must not be send.
+1 vote
by

Why not simply add a message: "By registering you agree to our Terms & Conditions".

by
Yes, this will be the simpliest way :o)

But i found a solution:
in the qa-page-register.php i add

'nutzung' => array(
                'type' => 'checkbox',
                'label' => 'Ich stimme den <a href="/index.php/nutzungsbedingungen">Nutzungsbedingungen und Regeln</a> zu.',
                'tags' => ' NAME="nutzung"',
                'error' => qa_html(@$errors['nutzung']),
                'value' => @$nutzung ? true : false,
            ),

After that i edit

    if (qa_clicked('doregister')) {
        require_once QA_INCLUDE_DIR.'qa-app-users-edit.php';
       
        $inemail=qa_post_text('email');
        $inpassword=qa_post_text('password');
        $inhandle=qa_post_text('handle');
       
        $nutzung=qa_post_text('nutzung');
       
and in this line:
if (empty($errors) && $nutzung == true)
i edit $nutzung == true for sending the post only, if $nutzung is true.

The errormessage for not checked button come from the qa-app-users-edit.php where is just wrote down
$errors['nutzung']='Sie müssen die Nutzungsbedingungen akzeptieren.';

Thats it.

At beginning i found it really hard to understand the coding, but now i get fun with it.

Greetz ManiBe
by
Good work and thanks for posting this. I'm sure it will be helpful for other people.
by
Found an error:

"The errormessage for not checked button come from the qa-app-users-edit.php where is just wrote down
$errors['nutzung']='Sie müssen die Nutzungsbedingungen akzeptieren.'; "
 
causes trouble and no one can register anymore.

Solution:
Delete the $errors['nutzung'] from qa-app-users-edit.php.
and edit qa-page-register.php in this way:

$errors=array_merge(
            qa_handle_email_validate($inhandle, $inemail),
            qa_password_validate($inpassword)
           
        );
       
        if ($nutzung == false)
        $errors['nutzung']='Sie müssen die Nutzungsbedingungen akzeptieren.';           
       
        if (qa_opt('captcha_on_register'))
            qa_captcha_validate($_POST, $errors);
   
        if (empty($errors) && $nutzung == true) {

Now it works perfectly.

Greetings ManiBe
by
Wow this is great help..
...