From d588cf14c97b93b57e62a26689197f605abdf6f7 Mon Sep 17 00:00:00 2001 From: Shramee Srivastav Date: Thu, 3 Mar 2016 17:28:56 +0530 Subject: [PATCH 1/2] Make User Tags field required option work --- core/um-actions-form.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/um-actions-form.php b/core/um-actions-form.php index 253ab682..4156598c 100644 --- a/core/um-actions-form.php +++ b/core/um-actions-form.php @@ -162,6 +162,10 @@ $ultimatemember->form->add_error($key, sprintf(__('%s is required.','ultimatemember'), $array['title'] ) ); } + if ( isset( $array['type'] ) && $array['type'] == 'user_tags' && isset( $array['required'] ) && $array['required'] == 1 && !isset( $args[$key] ) ) { + $ultimatemember->form->add_error($key, sprintf(__('%s is required.','ultimatemember'), $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') ) ) { $ultimatemember->form->add_error($key, sprintf(__('%s is required.','ultimatemember'), $array['title'] ) ); } From a0dd04384ee8fc45340436f3fa7876223498c1b0 Mon Sep 17 00:00:00 2001 From: Shramee Srivastav Date: Thu, 3 Mar 2016 17:46:50 +0530 Subject: [PATCH 2/2] Add option to require profile photo in profile form --- admin/templates/form/profile_customize.php | 10 +++++++++- core/um-actions-form.php | 4 ++++ core/um-actions-profile.php | 6 ++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/admin/templates/form/profile_customize.php b/admin/templates/form/profile_customize.php index d7d7bb05..162b074d 100644 --- a/admin/templates/form/profile_customize.php +++ b/admin/templates/form/profile_customize.php @@ -139,7 +139,15 @@

- + +

+ + + ui_on_off('_um_profile_photo_required'); ?> + + +

+

diff --git a/core/um-actions-form.php b/core/um-actions-form.php index 4156598c..96f11044 100644 --- a/core/um-actions-form.php +++ b/core/um-actions-form.php @@ -152,6 +152,10 @@ $form_id = $args['form_id']; $mode = $args['mode']; $fields = unserialize( $args['custom_fields'] ); + + if ( get_post_meta( $form_id, '_um_profile_photo_required', true ) && empty( $args['profile_photo'] ) ) { + $ultimatemember->form->add_error('profile_photo', sprintf(__('%s is required.','ultimatemember'), 'Profile Photo' ) ); + } if( isset( $fields ) && ! empty( $fields ) ){ foreach( $fields as $key => $array ) { diff --git a/core/um-actions-profile.php b/core/um-actions-profile.php index 2bd72d21..1366d4af 100644 --- a/core/um-actions-profile.php +++ b/core/um-actions-profile.php @@ -406,6 +406,12 @@
+ + fields->is_error( 'profile_photo' ) ) { + echo $ultimatemember->fields->field_error( $ultimatemember->fields->show_error('profile_photo'), 'force_show' ); + } + ?>