Merge pull request #1676 from ultimatemember/fix/extend_baneed_fields

Extend baneed fields
This commit is contained in:
Mykyta Synelnikov
2025-04-17 19:58:01 +03:00
committed by GitHub
6 changed files with 195 additions and 29 deletions
+7 -1
View File
@@ -34,6 +34,9 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
public $saved_fields = array();
/**
* Field keys that cannot be used as metakey when add new custom field to UM Form.
* Note: They are used both with function `UM()->user()->is_metakey_banned()` to avoid using unsecure metakeys.
*
* @var array
*/
public $blacklist_fields = array();
@@ -183,7 +186,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
* @return int|string Empty or error string.
*/
public function blacklist_field_err( $key ) {
if ( in_array( strtolower( $key ), $this->blacklist_fields, true ) ) {
if ( in_array( strtolower( $key ), $this->blacklist_fields, true ) || UM()->user()->is_metakey_banned( $key ) ) {
return __( 'Your meta key can not be used', 'ultimate-member' );
}
@@ -1426,6 +1429,9 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
public function set_blacklist_fields() {
$this->blacklist_fields = array(
'id',
'role',
'user_id',
'user_pass',
);
/**