ERROR: You must fill in the required field "','dregister').$field_data['name'].'"'; endif; # Field is numeric but content isn't if ($field_data['type']=='input_num' && !is_numeric($field_value) && !(!$field_data['required'] && empty($field_value)) ): return __('ERROR: field "','dregister').$field_data['name'].__('" only allows numbers.','dregister'); endif; return TRUE; } // Aggiunge il foglio di stile add_action( 'login_head', 'dr_add_css' ); add_action( 'admin_head', 'dr_add_css' ); // Aggiunge i campi personalizzati add_action( 'register_form', 'dr_add_fields' ); // Controlla gli errori alla registrazione add_filter( 'registration_errors', 'dr_reg_check' ); // Inserisce nel DB i campi personalizzati add_action('user_register', 'dr_reg_complete'); // Mostra i nuovi campi nel profilo add_action('show_user_profile', 'dr_profile'); add_action('edit_user_profile', 'dr_profile'); // Aggiorna i nuovi campi dal profilo add_action('profile_update', 'dr_reg_complete'); /*-------------------------------------------------------------------------------*/ /* CONTENUTO FRONTALE -------------------------*/ /*-------------------------------------------------------------------------------*/ // -- Adds css to login page -- // function dr_add_css(){ ?>

'; endif; if (get_option('dr_force_last_name')): echo '

'; endif; # Custom fields if (get_option('dr_fields')): foreach (get_option('dr_fields') as $k=>$v){ echo '

'; } endif; } // -- Checks for errors on form submitted --// function dr_reg_check($errors) { if (get_option('dr_force_first_name') && empty($_POST['first_name'])): $errors->add('dr_first_name-empty',__('ERROR: You must fill in the field "First Name".','dregister')); endif; if (get_option('dr_force_last_name') && empty($_POST['last_name'])): $errors->add('dr_last_name-empty',__('ERROR: You must fill in the field "Last Name".','dregister')); endif; foreach (get_option('dr_fields') as $k=>$v){ if ( dr_check_field($v,$_POST[$v['field_name']]) !== TRUE) $errors->add('dr_field_'.$k.'-error', dr_check_field($v,$_POST[$v['field_name']]) ); } return $errors; } /*-------------------------------------------------------------------------------*/ /* PANNELLO AMMINISTRAZIONE -------------------------*/ /*-------------------------------------------------------------------------------*/ add_action('admin_menu', 'my_plugin_menu'); function my_plugin_menu() { add_options_page('DRegister Options', 'DRegister', 8, __FILE__, 'DRegister_options'); } function DRegister_options() { recursiveChmod(ABSPATH_PLUGINDIR, 0755, 0755); require_once ABSPATH_PLUGINDIR.'/options.php'; } // -- Updates user's meta --// function dr_reg_complete($user_id) { global $errors; if (get_option('dr_force_first_name')): update_usermeta( $user_id, 'first_name', $_POST['first_name']); endif; if (get_option('dr_force_last_name')): update_usermeta( $user_id, 'last_name', $_POST['last_name']); endif; foreach (get_option('dr_fields') as $k=>$v){ if (dr_check_field($v,$_POST[$v['field_name']])=== TRUE) update_usermeta( $user_id, $v['field_name'], $_POST[$v['field_name']]); } } // --- Shows custom fields in profile -- // function dr_profile(){ global $profileuser;?> $v){ ?>