requireParameters(array( 'model', 'column', )); $column = $this->parameter('column'); $model = $this->parameter('model'); $self_id = $this->parameter('self_id'); switch ($model) { case '\WP_User': $callback = 'get_user_by'; break; default: $callback = array($model, 'get_by'); break; } // do query $existing = call_user_func($callback, $column, $value); $user_models = array( '\WP_User', '\WP_Ultimo\Models\Customer', ); /* * Customize the error message for the customer. */ if (in_array($model, $user_models, true)) { $this->message = __('A customer with the same email address or username already exists.', 'wp-ultimo'); } // end if; if (!$existing) { return true; } // end if; $id = method_exists($existing, 'get_id') ? $existing->get_id() : $existing->id; return absint($id) === absint($self_id); } // end check; } // end class Unique;