LLMS_REST_Users_Controller::update_additional_data( int $object_id, array $prepared, WP_REST_Request $request )

Updates additional information not handled by WP Core insert/update user functions


Parameters Parameters

$object_id

(int) (Required) WP User id.

$prepared

(array) (Required) Prepared item data.

$request

(WP_REST_Request) (Required) Request object.


Top ↑

Return Return

(LLMS_Abstract_User_Data|WP_error)


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/abstracts/class-llms-rest-users-controller.php

	 * Updates additional information not handled by WP Core insert/update user functions
	 *
	 * @since 1.0.0-beta.1
	 * @since 1.0.0-beta.10 Fixed setting roles instead of appending them.
	 * @since 1.0.0-beta.11 Made sure to set user's meta with the correct db key.
	 *
	 * @param int             $object_id WP User id.
	 * @param array           $prepared  Prepared item data.
	 * @param WP_REST_Request $request   Request object.
	 * @return LLMS_Abstract_User_Data|WP_error
	 */
	protected function update_additional_data( $object_id, $prepared, $request ) {

		$object = $this->get_object( $object_id );

		if ( is_wp_error( $object ) ) {
			return $object;
		}

		$metas = array(
			'billing_address_1',
			'billing_address_2',
			'billing_city',
			'billing_state',
			'billing_postcode',
			'billing_country',
		);

		$map = $this->map_schema_to_database();

		foreach ( $metas as $meta ) {
			if ( ! empty( $map[ $meta ] ) && ! empty( $prepared[ $map[ $meta ] ] ) ) {
				$object->set( $map[ $meta ], $prepared[ $map[ $meta ] ] );
			}
		}



Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.11 Made sure to set user's meta with the correct db key.
1.0.0-beta.10 Fixed setting roles instead of appending them.
1.0.0-beta.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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