forum.coppermine-gallery.net
Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: Guidonzolo 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
-
Please post the link of the cpg1.4.x thread.
-
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
-
Please post the link/url of the cpg1.4.x thread.
-
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
-
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?
-
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
-
Open register.php, find
$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
$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
$profile1 = $superCage->post->getEscaped('user_profile1');
and replace with
$profile1 = trim(get_post_var('user_profile1'));
find
if ($password != $password_again) {
$error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['password_verification_warning1'] . '</li>';
}
below, add
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
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
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
if (errors != 0) {
$('#form_not_submit_top').show();
$('#form_not_submit_bottom').show();
return false;
} else {
return true;
}
above, add
// Check user_profile1
if($('#user_profile1').val() == '') {
$('#user_profile1_warning1').show();
errors++;
} else {
if ($('#user_profile1').val().length < 2 ) {
$('#user_profile1_warning2').show();
errors++;
}
}
-
Thanks a lot.
It works fine.
Guido
-
Marking accordingly. Please do that yourself in the future.
-
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