From 206408e5132cfe3d4ebead1346519d9c9b0bf032 Mon Sep 17 00:00:00 2001 From: champsupertramp Date: Wed, 27 Jan 2016 19:15:47 +0800 Subject: [PATCH 1/2] Add option to allow users to hide profiles from member page --- core/um-account.php | 14 ++++++++++++++ um-config.php | 10 ++++++++++ 2 files changed, 24 insertions(+) diff --git a/core/um-account.php b/core/um-account.php index 1e34b95f..2a786194 100644 --- a/core/um-account.php +++ b/core/um-account.php @@ -12,6 +12,8 @@ class UM_Account { add_action('template_redirect', array(&$this, 'form_init'), 10002); + add_filter('um_predefined_fields_hook', array(&$this,'predefined_fields_hook'),1 ); + $this->current_tab = 'general'; } @@ -304,4 +306,16 @@ class UM_Account { $ultimatemember->shortcodes->load_template( $template ); } + /*** + ** @filter account fields + ****/ + function predefined_fields_hook( $predefined_fields ){ + + $account_hide_in_directory = um_get_option('account_hide_in_directory'); + if( ! $account_hide_in_directory ){ + unset( $predefined_fields['hide_in_members'] ); + } + + return $predefined_fields; + } } \ No newline at end of file diff --git a/um-config.php b/um-config.php index c70f2b91..15ebc9bc 100644 --- a/um-config.php +++ b/um-config.php @@ -274,6 +274,16 @@ $this->sections[] = array( 'off' => __('Off','ultimatemember'), ), + array( + 'id' => 'account_hide_in_directory', + 'type' => 'switch', + 'title' => __( 'Allow users to hide their profiles from directory','ultimatemember' ), + 'default' => 1, + 'desc' => __('Whether to allow users changing their profile visibility from member directory in account page.','ultimatemember'), + 'on' => __('On','ultimatemember'), + 'off' => __('Off','ultimatemember'), + ), + array( 'id' => 'account_require_strongpass', 'type' => 'switch', From 78923c8bbbf3271e26dd463c3c97bd2531c5873c Mon Sep 17 00:00:00 2001 From: champsupertramp Date: Thu, 28 Jan 2016 11:11:28 +0800 Subject: [PATCH 2/2] Add image upload notice --- core/um-files.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/um-files.php b/core/um-files.php index 7190dff8..951a0c8a 100644 --- a/core/um-files.php +++ b/core/um-files.php @@ -290,6 +290,12 @@ class UM_Files { $array['image'] = @getimagesize($file); + if ( empty( $_FILES['tmp_name'] ) ){ + $array['invalid_image'] = true; + $array['error_type'] = 'too_large'; + return $array; + } + if ( $array['image'] > 0 ) { $array['invalid_image'] = false; @@ -329,7 +335,11 @@ class UM_Files { } if ( $fileinfo['invalid_image'] == true ) { - $error = sprintf(__('Your image is invalid or too large!','ultimatemember') ); + if( isset( $fileinfo['error_type'] ) && $fileinfo['error_type'] == 'too_large' ){ + $error = sprintf(__('The uploaded image was too large. You must upload a file smaller than %s','ultimatemember') , ini_get("upload_max_filesize") ); + }else{ + $error = sprintf(__('Your image is invalid or too large!','ultimatemember') ); + } } elseif ( isset( $data['allowed_types'] ) && !$this->in_array( $fileinfo['extension'], $data['allowed_types'] ) ) { $error = ( isset( $data['extension_error'] ) && !empty( $data['extension_error'] ) ) ? $data['extension_error'] : 'not allowed'; } elseif ( isset($data['min_size']) && ( $fileinfo['size'] < $data['min_size'] ) ) {