mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-19 14:43:49 +09:00
- fixed issue #376
This commit is contained in:
@@ -1218,6 +1218,8 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
/**
|
||||
* Get all fields without metakeys
|
||||
*
|
||||
* @since 2.0.56
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_fields_without_metakey() {
|
||||
|
||||
@@ -26,22 +26,26 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
var $form_id;
|
||||
|
||||
|
||||
/**
|
||||
* @var null
|
||||
*/
|
||||
var $post_form = null;
|
||||
|
||||
|
||||
/**
|
||||
* Form constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
|
||||
$this->post_form = null;
|
||||
|
||||
$this->form_suffix = null;
|
||||
|
||||
$this->errors = null;
|
||||
|
||||
$this->processing = null;
|
||||
|
||||
add_action('template_redirect', array(&$this, 'form_init'), 2);
|
||||
add_action( 'template_redirect', array( &$this, 'form_init' ), 2 );
|
||||
|
||||
add_action('init', array(&$this, 'field_declare'), 10);
|
||||
add_action( 'init', array( &$this, 'field_declare' ), 10 );
|
||||
|
||||
}
|
||||
|
||||
@@ -218,8 +222,9 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
* @return boolean
|
||||
*/
|
||||
function has_error( $key ) {
|
||||
if ( isset( $this->errors[$key] ) )
|
||||
if ( isset( $this->errors[ $key ] ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -227,7 +232,7 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
/**
|
||||
* Declare all fields
|
||||
*/
|
||||
function field_declare(){
|
||||
function field_declare() {
|
||||
if ( isset( UM()->builtin()->custom_fields ) ) {
|
||||
$this->all_fields = UM()->builtin()->custom_fields;
|
||||
} else {
|
||||
@@ -237,11 +242,11 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
|
||||
|
||||
/**
|
||||
* Validate form
|
||||
* Validate form on submit
|
||||
*/
|
||||
function form_init() {
|
||||
if ( isset( $_SERVER['REQUEST_METHOD'] ) ) {
|
||||
$http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
|
||||
$http_post = ( 'POST' == $_SERVER['REQUEST_METHOD'] );
|
||||
} else {
|
||||
$http_post = 'POST';
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ function um_submit_form_errors_hook_( $args ) {
|
||||
$um_profile_photo = um_profile('profile_photo');
|
||||
|
||||
if ( get_post_meta( $form_id, '_um_profile_photo_required', true ) && ( empty( $args['profile_photo'] ) && empty( $um_profile_photo ) ) ) {
|
||||
UM()->form()->add_error('profile_photo', sprintf(__('%s is required.','ultimate-member'), 'Profile Photo' ) );
|
||||
UM()->form()->add_error('profile_photo', __( 'Profile Photo is required.', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $fields ) ) {
|
||||
@@ -413,7 +413,7 @@ function um_submit_form_errors_hook_( $args ) {
|
||||
}
|
||||
|
||||
if ( isset( $array['type'] ) && $array['type'] == 'checkbox' && isset( $array['required'] ) && $array['required'] == 1 && !isset( $args[$key] ) ) {
|
||||
UM()->form()->add_error($key, sprintf(__('%s is required.','ultimate-member'), $array['title'] ) );
|
||||
UM()->form()->add_error($key, sprintf( __( '%s is required.', 'ultimate-member' ), $array['title'] ) );
|
||||
}
|
||||
|
||||
if ( isset( $array['type'] ) && $array['type'] == 'radio' && isset( $array['required'] ) && $array['required'] == 1 && !isset( $args[$key] ) && !in_array($key, array('role_radio','role_select') ) ) {
|
||||
@@ -453,17 +453,17 @@ function um_submit_form_errors_hook_( $args ) {
|
||||
*/
|
||||
do_action( 'um_add_error_on_form_submit_validation', $array, $key, $args );
|
||||
|
||||
if ( isset( $args[ $key ] ) ) {
|
||||
|
||||
if ( isset( $array['required'] ) && $array['required'] == 1 ) {
|
||||
if ( ! isset( $args[$key] ) || $args[$key] == '' || $args[$key] == 'empty_file') {
|
||||
if( empty( $array['label'] ) ) {
|
||||
UM()->form()->add_error($key, __('This field is required','ultimate-member') );
|
||||
} else {
|
||||
UM()->form()->add_error($key, sprintf( __('%s is required','ultimate-member'), $array['label'] ) );
|
||||
}
|
||||
if ( ! empty( $array['required'] ) ) {
|
||||
if ( ! isset( $args[ $key ] ) || $args[ $key ] == '' || $args[ $key ] == 'empty_file' ) {
|
||||
if ( empty( $array['label'] ) ) {
|
||||
UM()->form()->add_error( $key, __( 'This field is required', 'ultimate-member' ) );
|
||||
} else {
|
||||
UM()->form()->add_error( $key, sprintf( __( '%s is required', 'ultimate-member' ), $array['label'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $args[ $key ] ) ) {
|
||||
|
||||
if ( isset( $array['max_words'] ) && $array['max_words'] > 0 ) {
|
||||
if ( str_word_count( $args[$key], 0, "éèàôù" ) > $array['max_words'] ) {
|
||||
|
||||
Reference in New Issue
Block a user