field required at registration field required at registration
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

field required at registration

Started by studeo, October 08, 2006, 06:07:03 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

studeo

Hi:

I have searched through the help and topic files but I have not found exactly what I am looking for.

Tonight I received an email as admin for a new user registration. I have set my cpg up to notify me and I will be responsible for activating the user (its a family site). This person only gave a user name.

I would like to make the location field and email field as well as an optional Full Name field I have added to profile line 5 a *required* field so I might know who this is trying to register. I have found various posts addressing javascripts, etc. but cound not find a definitive addition to make these fields required. Can you offer any suggestions? I will gladly pay my one karma point for this answer :)

Maybe someone can point me to a link if already aswered somewhere.

Thank you.

studeo


Sami

Javascript would be the simple way
- Disabling the submit button until *required* fields have value
‍I don't answer to PM with support question
Please post your issue to related board

studeo

#3
Where would you say in the code that I would find and put in a javascript? I have to admit I am an html designer just learning about php and others...I'm used to looking at html code pages but I get a bit lost still in php without edit hints.

Thanks in advance

Sami

Take a look at register.php
That file will:
- create registration form
- validate inputs
- insert , inputs to DB
so you should put your JS to this file on form creation part
‍I don't answer to PM with support question
Please post your issue to related board

studeo

Thank you. I have been looking at register.php all morning and sadly I have to admit I have no clue where and what to add. I'm sorry to bother you again but can you provide more detailed information to accomplish this?

Thanks

Sami

Can you write a JS to disable the form (button) until required field got filled?
You wrote it and I'll let you know where to put it ;)
‍I don't answer to PM with support question
Please post your issue to related board

studeo

No I can't But I had found this code from Paver to require an image title to be submitted so I would think that it needs to be modified to require the registrar's email addess and my user field #5 titled 'Full Name' to be entered before submit.

Thanks for hanging in there with me and maybe you can help me tweak this js code. I wish I could write code like you can.


function open_form($path) {

    echo <<<EOT
    <script language="javascript" type="text/javascript">
    function textCounter(field, maxlimit) {
            if (field.value.length > maxlimit) // if too long...trim it!
            field.value = field.value.substring(0, maxlimit);
    }
    function ValidateForm(form) {
            title = form.title.value;
            title = title.replace(/^\s*/, '').replace(/\s*$/, '');
            if (title.length == 0) {
alert("You must enter a title."); // not language-compatible
form.title.focus();
return false;
            }
            return true;
    }
    </script>
    <form method="post" action="$path" enctype="multipart/form-data" name="upload_form" onSubmit="javascript:return ValidateForm(this)">
EOT;
}

Sami

I take back my previous suggestion , I think there could be an easy way without injecting any JS code ;)
Right now I should go, but I'll post instruction when I come back (maybe other supporter post it before me )
‍I don't answer to PM with support question
Please post your issue to related board

studeo

As a related issue, when we make the *required* fields effective, I would like to include the *email* field, and the Full Name field into the activation email I receive as admin. I find the code {USER_NAME} is include in there so how will I add the email field and the user field #5?

Thanks

Sami

#10
Okey , Lets try to set FullName (custom field 5 for user Profile) as a mandatory field on registration:

- First you should go to config page and put FullName  on Profile 5 name (config=>Custom fields for user profile =>Profile 5 name)

- Open register.php from gallery root , around line 69~82 you  will find this:


    $form_data = array(
        array('label', $lang_register_php['required_info']),
        array('input', 'username', $lang_register_php['username'], 25),
        array('password', 'password', $lang_register_php['password'], 25),
        array('password', 'password_verification', $lang_register_php['password_again'], 25),
        array('input', 'email', $lang_register_php['email'], 255),
array('label', $lang_register_php['optional_info']),
                array('input', 'user_profile1', $CONFIG['user_profile1_name'], 255),
                array('input', 'user_profile2', $CONFIG['user_profile2_name'], 255),
                array('input', 'user_profile3', $CONFIG['user_profile3_name'], 255),
                array('input', 'user_profile4', $CONFIG['user_profile4_name'], 255),
                array('input', 'user_profile5', $CONFIG['user_profile5_name'], 255),
               array('textarea', 'user_profile6', $CONFIG['user_profile6_name'], 255)
        );



Replace it with


    $form_data = array(
        array('label', $lang_register_php['required_info']),
        array('input', 'username', $lang_register_php['username'], 25),
        array('password', 'password', $lang_register_php['password'], 25),
        array('password', 'password_verification', $lang_register_php['password_again'], 25),
        array('input', 'email', $lang_register_php['email'], 255),
        array('input', 'user_profile5', $CONFIG['user_profile5_name'], 255),// Added for fullname mandatory Mod
array('label', $lang_register_php['optional_info']),
                array('input', 'user_profile1', $CONFIG['user_profile1_name'], 255),
                array('input', 'user_profile2', $CONFIG['user_profile2_name'], 255),
                array('input', 'user_profile3', $CONFIG['user_profile3_name'], 255),
                array('input', 'user_profile4', $CONFIG['user_profile4_name'], 255),
//              array('input', 'user_profile5', $CONFIG['user_profile5_name'], 255), // Commented for fullname mandatory Mod
               array('textarea', 'user_profile6', $CONFIG['user_profile6_name'], 255)
        );


- Around line 222~228 you will find this:


    $email = trim(get_post_var('email'));
        $profile1 = addslashes($_POST['user_profile1']);
        $profile2 = addslashes($_POST['user_profile2']);
        $profile3 = addslashes($_POST['user_profile3']);
        $profile4 = addslashes($_POST['user_profile4']);
        $profile5 = addslashes($_POST['user_profile5']);
$profile6 = addslashes($_POST['user_profile6']);


Replace it with this:


    $email = trim(get_post_var('email'));
    $profile5 = trim(get_post_var('user_profile5')); // Added for fullname mandatory Mod
        $profile1 = addslashes($_POST['user_profile1']);
        $profile2 = addslashes($_POST['user_profile2']);
        $profile3 = addslashes($_POST['user_profile3']);
        $profile4 = addslashes($_POST['user_profile4']);
//      $profile5 = addslashes($_POST['user_profile5']); // Commented for fullname mandatory Mod
$profile6 = addslashes($_POST['user_profile6']);


- Put this


    if (utf_strlen($profile5) < 2) $error .= '<li>' . "Full name must be 2 characters long minimum"; // Added for fullname mandatory Mod


right after this(around line 241~242):


    if ($password != $password_again) $error .= '<li>' . $lang_register_php['err_password_mismatch'];


Now you are Done ....
‍I don't answer to PM with support question
Please post your issue to related board

studeo

#11
Thank you for the reply. I have changed/added your code to my register.php page.

QuoteFirst you should go to config page and put FullName  on Profile 5 name (config=>Custom fields for user profile =>Profile 5 name)

Are you referring to the config.php page in the root or some section in another document? When this is clarified I will run a test. Thanks Sami!

EDIT: I went ahead and tested this without resolving you first comment about config and all seems to work as expected. I could not register without filling out the the name, password, email and full name lines. I would like the admin activation email to include the fields 'email' and 'full name' as I mention earlier.  Thank you very much!!!!!

Sami

just login as an admin , click on config button and go to custom fields for user profile ... section and set the profile 5 name to Fullname
‍I don't answer to PM with support question
Please post your issue to related board

studeo

Thanks. Does 'Fullname' mean that cpg expects to find this field title as one word? As opposed to 'Full Name'  ?

Sami

No it's okey put there anything you want ;)
‍I don't answer to PM with support question
Please post your issue to related board

Sami

And now we are going to put Full name and user e-mail address to admin activation mail :

- Open Register.php from gallery root , around line 317~323 you will find:


                                                        $template_vars = array(
                                                                        '{SITE_NAME}' => $CONFIG['gallery_name'],
                                                                        '{USER_NAME}' => $user_name,
                                                                        '{ACT_LINK}' => $act_link,
        );


Replace it with this


                                                        $template_vars = array(
                                                                        '{SITE_NAME}' => $CONFIG['gallery_name'],
                                                                        '{USER_NAME}' => $user_name,
                                                                        '{ACT_LINK}' => $act_link,
        '{USER_MAIL}' => $email,// Added for Fullname mandatory Mod
        '{USER_FULLNAME}' => $profile5,// Added for Fullname mandatory Mod
                                                        );


- Open english.php from {gallery root}/lang, around line 1559 ~1570 you will find this:


$lang_register_approve_email = <<<EOT
A new user with the username "{USER_NAME}" has registered in your gallery.

In order to activate the account, you need to click on the link below or copy and paste it in your web browser.

<a href="{ACT_LINK}">{ACT_LINK}</a>

EOT;


Replace it with this:


$lang_register_approve_email = <<<EOT
A new user with

the username "{USER_NAME}"

and FullName "{USER_FULLNAME}"

and E-mail Address "{USER_MAIL}"

has registered in your gallery.

In order to activate the account, you need to click on the link below or copy and paste it in your web browser.

<a href="{ACT_LINK}">{ACT_LINK}</a>

EOT;


And now you are done !

I didn't test it yet but it should work AFAIK , check it and confirm .... ;)
‍I don't answer to PM with support question
Please post your issue to related board

studeo

Sami...

Thank you very much for the assistance. Everything works as expected.
People with family photo sites might like the extra security info in order allow users in.

Again, Thank you!

Studeo

loubymar

My Gallery is at: http://www.anastaciaisgreatgallery.co.nr
Coppermine version: 1.4.8

Instead of having the full name i changed it to date of birth, but when users register they can enter just their year e.g. 1990, but i want them to enter their full date of birth, e.g. 06/09/1990 is they away of doing this plz??

Sami

#18
You can use regular expression on this line :

if (utf_strlen($profile5) < 2) $error .= '<li>' . "Full name must be 2 characters long minimum"; // Added for fullname mandatory Mod


[Edit]
something like this could help you :
Replace this:


if (utf_strlen($profile5) < 2) $error .= '<li>' . "Full name must be 2 characters long minimum"; // Added for fullname mandatory Mod


with this:

if (utf_strlen($profile5) < 8 || !eregi("^([0-9]{2})+/+([0-9]{2})+/+[0-9]{4}$",$profile5)) $error .= '<li>' . "Birthday must be like this 16/09/2000 "; // Added for fullname mandatory Mod
‍I don't answer to PM with support question
Please post your issue to related board

hozyali

Hello,

I know this is an old topic but this is exactly what I need.

I wanted to make a few custom fields mandatory and I did the same as Sami described. But if I submit the form all empty, I get this error.
Script called without the required parameter(s). (user_profile5)

I doubled checked the register.php file to make sure I did everything correctly as specified. but it didn't help.
I am using version 1.4.8

Thanks