Advanced search  

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]

Pages: [1] 2   Go Down

Author Topic: field required at registration  (Read 15973 times)

0 Members and 1 Guest are viewing this topic.

studeo

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 50
field required at registration
« on: October 08, 2006, 06:07:03 am »

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.
« Last Edit: October 10, 2006, 04:44:28 pm by Sami »
Logged

studeo

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 50
Re: field required at registration
« Reply #1 on: October 09, 2006, 12:56:16 am »

Is this too tough a question?
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: field required at registration
« Reply #2 on: October 09, 2006, 06:28:30 am »

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

studeo

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 50
Re: field required at registration
« Reply #3 on: October 09, 2006, 03:25:11 pm »

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
« Last Edit: October 09, 2006, 03:31:14 pm by studeo »
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: field required at registration
« Reply #4 on: October 09, 2006, 03:40:28 pm »

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
Logged
‍I don't answer to PM with support question
Please post your issue to related board

studeo

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 50
Re: field required at registration
« Reply #5 on: October 09, 2006, 05:46:27 pm »

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
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: field required at registration
« Reply #6 on: October 09, 2006, 06:00:27 pm »

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 ;)
Logged
‍I don't answer to PM with support question
Please post your issue to related board

studeo

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 50
Re: field required at registration
« Reply #7 on: October 09, 2006, 06:27:24 pm »

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.


Code: [Select]
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;
}
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: field required at registration
« Reply #8 on: October 09, 2006, 07:15:02 pm »

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 )
Logged
‍I don't answer to PM with support question
Please post your issue to related board

studeo

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 50
Re: field required at registration
« Reply #9 on: October 09, 2006, 10:45:32 pm »

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
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: field required at registration
« Reply #10 on: October 10, 2006, 03:34:40 pm »

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:

Code: [Select]
    $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

Code: [Select]
    $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:

Code: [Select]
    $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:

Code: [Select]
    $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

Code: [Select]
    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):

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

Now you are Done ....
« Last Edit: October 10, 2006, 04:17:17 pm by Sami »
Logged
‍I don't answer to PM with support question
Please post your issue to related board

studeo

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 50
Re: field required at registration
« Reply #11 on: October 10, 2006, 03:58:33 pm »

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

Quote
First 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!!!!!
« Last Edit: October 10, 2006, 04:08:13 pm by studeo »
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: field required at registration
« Reply #12 on: October 10, 2006, 04:06:18 pm »

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
Logged
‍I don't answer to PM with support question
Please post your issue to related board

studeo

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 50
Re: field required at registration
« Reply #13 on: October 10, 2006, 04:09:48 pm »

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

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: field required at registration
« Reply #14 on: October 10, 2006, 04:15:17 pm »

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

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: field required at registration
« Reply #15 on: October 10, 2006, 04:18:03 pm »

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:

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

Replace it with this

Code: [Select]
                                                        $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:

Code: [Select]
$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:

Code: [Select]
$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 .... ;)
Logged
‍I don't answer to PM with support question
Please post your issue to related board

studeo

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 50
Re: field required at registration
« Reply #16 on: October 10, 2006, 04:27:17 pm »

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
Logged

loubymar

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 83
Re: field required at registration
« Reply #17 on: October 16, 2006, 07:16:23 pm »

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??
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: field required at registration
« Reply #18 on: October 16, 2006, 07:51:33 pm »

You can use regular expression on this line :
Code: [Select]
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:

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

with this:
Code: [Select]
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
« Last Edit: October 16, 2006, 09:04:00 pm by Sami »
Logged
‍I don't answer to PM with support question
Please post your issue to related board

hozyali

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 109
  • HozyAli
    • Starcom Hosting
Re: field required at registration
« Reply #19 on: July 28, 2008, 09:09:46 pm »

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.
Code: [Select]
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
Logged
Pages: [1] 2   Go Up
 

Page created in 0.036 seconds with 21 queries.