LLMS_Admin_Profile::save_user_meta_fields( int $user_id )

Maybe save user meta fields


Parameters Parameters

$user_id

(int) (Required) WP_User ID for the user being updated.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/admin/class-llms-admin-profile.php

	public function save_user_meta_fields( $user_id ) {

		if ( ! $this->current_user_can_edit_admin_custom_fields() ) {
			return;
		}

		$fields      = $this->get_fields();
		$posted_data = array();

		foreach ( $this->fields as $field ) {
			//phpcs:disable WordPress.Security.NonceVerification.Missing  -- nonce is verified prior to reaching this method.
			if ( isset( $_POST[ $field['name'] ] ) &&
					isset( $field['data_store_key'] ) &&
						$field['data_store'] && 'usermeta' === $field['data_store'] ) {
				//phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash -- sanitization and unslashing happens in `LLMS_Form_Handler::instance()->submit_form_fields()` below.
				$posted_data[ $field['name'] ] = $_POST[ $field['name'] ];
			}
			//phpcs:disable WordPress.Security.NonceVerification.Missing
		}

		if ( empty( $posted_data ) ) {
			return;
		}

		$posted_data['user_id'] = $user_id;

		$submit = LLMS_Form_Handler::instance()->submit_fields( $posted_data, 'admin-profile', $fields, 'update' );

		if ( is_wp_error( $submit ) ) {
			$this->errors = $submit;
		}

	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.