ACF_Form_User::save_user
Saves ACF field values to a user.
Метод класса: ACF_Form_User{}
Хуков нет.
Возвращает
integer|void.
Использование
$ACF_Form_User = new ACF_Form_User(); $ACF_Form_User->save_user( $user_id );
- $user_id(int) (обязательный)
- The ID of the user being saved.
Список изменений
| С версии 5.0.0 | Введена. |
Код ACF_Form_User::save_user() ACF Form User::save user ACF 6.8.8
public function save_user( $user_id ) {
if ( ! acf_verify_nonce( 'user' ) ) {
return $user_id;
}
if ( isset( $_POST['acf'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified above.
if ( ! is_array( $_POST['acf'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified above.
return $user_id;
}
// Restrict $_POST['acf'] to keys of fields belonging to field groups that apply to this user.
$allowed_keys = $this->get_allowed_field_keys( $user_id );
$_POST['acf'] = array_intersect_key( $_POST['acf'], array_flip( $allowed_keys ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash -- Verified above; sanitized downstream.
if ( empty( $_POST['acf'] ) ) {
return $user_id;
}
}
// save
if ( acf_validate_save_post( true ) ) {
acf_save_post( "user_$user_id" );
}
}