diff --git a/includes/admin/core/class-admin-builder.php b/includes/admin/core/class-admin-builder.php index 1ed73dbc..7787114f 100644 --- a/includes/admin/core/class-admin-builder.php +++ b/includes/admin/core/class-admin-builder.php @@ -86,6 +86,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) { continue; } + $blacklist_error = UM()->builtin()->blacklist_field_err( $submission_data['post']['_metakey'] ); + if ( ! empty( $blacklist_error ) ) { + $errors['_metakey'] = $blacklist_error; + } + switch ( $arr['mode'] ) { case 'numeric': if ( ! empty( $submission_data['post'][ $post_input ] ) && ! is_numeric( $submission_data['post'][ $post_input ] ) ) { diff --git a/includes/core/class-builtin.php b/includes/core/class-builtin.php index d4bf45bf..ad27a38c 100644 --- a/includes/core/class-builtin.php +++ b/includes/core/class-builtin.php @@ -168,9 +168,6 @@ if ( ! class_exists( 'um\core\Builtin' ) ) { if ( isset( $this->saved_fields[ $key ] ) ) { return __( 'Your meta key already exists in your fields list', 'ultimate-member' ); } - if ( in_array( $key, $this->blacklist_fields, true ) ) { - return __( 'Your meta key can not be used', 'ultimate-member' ); - } if ( ! UM()->validation()->safe_string( $key ) ) { return __( 'Your meta key contains illegal characters. Please correct it.', 'ultimate-member' ); } @@ -179,6 +176,22 @@ if ( ! class_exists( 'um\core\Builtin' ) ) { } + /** + * Checks for a blacklist field error + * + * @param $key + * + * @return int|string + */ + public function blacklist_field_err( $key ) { + if ( in_array( strtolower( $key ), UM()->builtin()->blacklist_fields, true ) ) { + return __( 'Your meta key can not be used', 'ultimate-member' ); + } + + return 0; + } + + /** * Check date range errors (start date) * @@ -1365,30 +1378,26 @@ if ( ! class_exists( 'um\core\Builtin' ) ) { public function set_blacklist_fields() { - $this->blacklist_fields = array( - 'ID', + 'id', ); /** - * UM hook + * Filters change metakeys in the blacklist. * - * @type filter - * @title um_blacklist_fields_hook - * @description Extend Blacklist Fields - * @input_vars - * [{"var":"$blacklist_fields","type":"array","desc":"Blacklist Fields"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_blacklist_fields_hook', 'function_name', 10, 1 ); - * @example - * Change array of metakeys in the blacklist. + * function my_um_blacklist_fields_hook( $blacklist_fields ) { * // your code here * return $blacklist_fields; * } - * ?> + * add_filter( 'um_blacklist_fields_hook', 'my_um_blacklist_fields_hook' ); */ $this->blacklist_fields = apply_filters( 'um_blacklist_fields_hook', $this->blacklist_fields ); }