mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- add the ID to the blacklist of meta key
This commit is contained in:
@@ -33,6 +33,11 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
*/
|
||||
public $saved_fields = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $blacklist_fields = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@@ -50,6 +55,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
add_action( 'init', array( &$this, 'set_core_fields' ), 1 );
|
||||
add_action( 'init', array( &$this, 'set_predefined_fields' ), 1 );
|
||||
add_action( 'init', array( &$this, 'set_custom_fields' ), 1 );
|
||||
add_action( 'init', array( &$this, 'set_blacklist_fields' ), 1 );
|
||||
$this->saved_fields = get_option( 'um_fields', array() );
|
||||
}
|
||||
|
||||
@@ -149,7 +155,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
*
|
||||
* @return int|string
|
||||
*/
|
||||
function unique_field_err( $key ) {
|
||||
public function unique_field_err( $key ) {
|
||||
if ( empty( $key ) ) {
|
||||
return __( 'Please provide a meta key', 'ultimate-member' );
|
||||
}
|
||||
@@ -162,6 +168,9 @@ 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' );
|
||||
}
|
||||
@@ -1355,6 +1364,36 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
|
||||
}
|
||||
|
||||
|
||||
public function set_blacklist_fields() {
|
||||
|
||||
$this->blacklist_fields = array(
|
||||
'ID',
|
||||
);
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @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
|
||||
* <?php
|
||||
* add_filter( 'um_blacklist_fields_hook', 'my_blacklist_fields', 10, 1 );
|
||||
* function my_blacklist_fields( $blacklist_fields ) {
|
||||
* // your code here
|
||||
* return $blacklist_fields;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$this->blacklist_fields = apply_filters( 'um_blacklist_fields_hook', $this->blacklist_fields );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Custom Fields
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user