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]   Go Down

Author Topic: Make Custom Fields for User Profile Required Instead of Optional  (Read 7311 times)

0 Members and 1 Guest are viewing this topic.

Guidonzolo

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Make Custom Fields for User Profile Required Instead of Optional
« on: February 07, 2011, 08:32:36 pm »

Hello,
I'm finding a way to make custom fields of user profile required. I've find some solution for Coppermine 1.4 but, with the last version 1.5.12, I think there are some changes because i'm not able to follow the suggests for the 1.4x version.
Can anyone help me?
Thanks
Guidonzolo
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Make Custom Fields for User Profile Required Instead of Optional
« Reply #1 on: February 08, 2011, 10:05:55 am »

Please post the link of the cpg1.4.x thread.
Logged

Guidonzolo

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Make Custom Fields for User Profile Required Instead of Optional
« Reply #2 on: February 09, 2011, 09:58:39 am »

Thanks for you replay.
I've posted on 1.5 because of i've the last version. The threads that i've read on 1.4 forum refer about a register.php page that is different from the register.php of the last version.
Guido S
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Make Custom Fields for User Profile Required Instead of Optional
« Reply #3 on: February 09, 2011, 10:34:20 am »

Please post the link/url of the cpg1.4.x thread.
Logged

Guidonzolo

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Make Custom Fields for User Profile Required Instead of Optional
« Reply #4 on: February 09, 2011, 10:47:30 am »

http://forum.coppermine-gallery.net/index.php/topic,37086.0.html

Here there are some code modifications but i cannot find that code lines on my registration.php page
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Make Custom Fields for User Profile Required Instead of Optional
« Reply #5 on: February 09, 2011, 04:40:15 pm »

The instructions from that thread still applies, but the code has slightly changed, so you shouldn't search for the exact code Sami referred to.

Which custom fields do you want to make mandatory?
Logged

Guidonzolo

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Make Custom Fields for User Profile Required Instead of Optional
« Reply #6 on: February 10, 2011, 10:30:10 am »

I want to make mandatory the first custom field. This field is "Full Name", because on my site, i allow access only to my friends.
Thanks

Guido
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Make Custom Fields for User Profile Required Instead of Optional
« Reply #7 on: February 10, 2011, 02:46:09 pm »

Open register.php, find
Code: [Select]
    $form_data = array(
        array('label', $lang_register_php['required_info']),
        array('input', 'username', $icon_array['username'] . $lang_register_php['username'], 25),
        array('password', 'global_registration_pw', $icon_array['password'] . $lang_register_php['global_registration_pw'], 25),
        array('password', 'password', $icon_array['password'] . $lang_register_php['password']),
        array('password', 'password_verification', $icon_array['password'] . $lang_register_php['password_again']),
        array('input', 'email', $icon_array['email'] . $lang_register_php['email'], 255),
        array('label', $lang_register_php['optional_info'])
    );
    $optional_data = 0;
    if ($CONFIG['user_profile1_name'] != '') {
        $form_data[] = array('input', 'user_profile1', $icon_array['blank'] . $CONFIG['user_profile1_name'], 255);
        $optional_data++;
    }
and replace with
Code: [Select]
    $form_data = array(
        array('label', $lang_register_php['required_info']),
        array('input', 'username', $icon_array['username'] . $lang_register_php['username'], 25),
        !empty($CONFIG['global_registration_pw']) ? array('password', 'global_registration_pw', $icon_array['password'] . $lang_register_php['global_registration_pw'], 25) : '',
        array('password', 'password', $icon_array['password'] . $lang_register_php['password']),
        array('password', 'password_verification', $icon_array['password'] . $lang_register_php['password_again']),
        array('input', 'email', $icon_array['email'] . $lang_register_php['email'], 255),
        !empty($CONFIG['user_profile1_name']) ? array('input', 'user_profile1', $icon_array['blank'] . $CONFIG['user_profile1_name'], 255) : '',
        array('label', $lang_register_php['optional_info'])
    );
    $optional_data = 0;

find
Code: [Select]
$profile1 = $superCage->post->getEscaped('user_profile1');and replace with
Code: [Select]
$profile1 = trim(get_post_var('user_profile1'));
find
Code: [Select]
    if ($password != $password_again) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['password_verification_warning1'] . '</li>';
    }
below, add
Code: [Select]
    if (utf_strlen($profile1) < 2) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">Value \'' . $CONFIG['user_profile1_name'] . '\' must be at least two characters long!</li>';
    }


If you want to show an error message before the form will be submitted, open register.php, find
Code: [Select]
            if (isset($lang_register_php[$element[1].'_warning2']) == TRUE) {
                $warning2 = '<div id="'.$element[1].'_warning2" class="cpg_message_validation formFieldWarning" style="display:none;">' . $lang_register_php[$element[1].'_warning2'] . '</div>';
            } else {
                $warning2 = '';
            }
below, add
Code: [Select]
            if ($element[1] == 'user_profile1') {
                $warning1 = '<div id="user_profile1_warning1" class="cpg_message_validation formFieldWarning" style="display:none;">';
                $warning1 .= 'The ' . $CONFIG['user_profile1_name'] . ' mustn\'t be empty!';
                $warning1 .= '</div>';
                $warning2 = '<div id="user_profile1_warning2" class="cpg_message_validation formFieldWarning" style="display:none;">';
                $warning2 .= 'The ' . $CONFIG['user_profile1_name'] . ' must be at least two characters long!';
                $warning2 .= '</div>';
            }

open js/register.js, find
Code: [Select]
    if (errors != 0) {
        $('#form_not_submit_top').show();
        $('#form_not_submit_bottom').show();
        return false;
    } else {
        return true;
    }
above, add
Code: [Select]
    // Check user_profile1
    if($('#user_profile1').val() == '') {
        $('#user_profile1_warning1').show();
        errors++;
    } else {
        if ($('#user_profile1').val().length < 2 ) {
            $('#user_profile1_warning2').show();
            errors++;
        }
    }
Logged

Guidonzolo

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Make Custom Fields for User Profile Required Instead of Optional
« Reply #8 on: February 10, 2011, 07:14:51 pm »

Thanks a lot.
It works fine.

Guido
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Make Custom Fields for User Profile Required Instead of Optional
« Reply #9 on: February 11, 2011, 10:30:07 am »

Marking accordingly. Please do that yourself in the future.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Make Custom Fields for User Profile Required Instead of Optional
« Reply #10 on: March 18, 2011, 03:19:16 pm »

If somebody wants to make all custom fields required, have a look at that solution: http://forum.coppermine-gallery.net/index.php/topic,71395.msg347486.html#msg347486
Logged
Pages: [1]   Go Up
 

Page created in 0.021 seconds with 20 queries.