LLMS_Post_Model::set_bulk( array $model_array, array $wp_error = false, boolean $allow_same_meta_value = false )

Bulk setter.


Parameters Parameters

$model_array

(array) (Required) Associative array of key/val pairs.

$wp_error

(array) (Optional) Whether or not return a WP_Error.

Default value: false

$allow_same_meta_value

(boolean) (Optional) Whether or not updating a meta with the same value as stored in the db is allowed.

Default value: false


Top ↑

Return Return

(boolean|WP_Error) True on success. If the param $wp_error is set to false this will be false on error or if there was nothing to update. Otherwise, this will be a WP_Error object collecting all the errors encountered along the way.


Top ↑

Source Source

File: includes/abstracts/abstract.llms.post.model.php

	public function set_bulk( $model_array, $wp_error = false, $allow_same_meta_value = false ) {

		if ( empty( $model_array ) ) {
			return $wp_error ? new WP_Error( 'empty_data', __( 'Empty data', 'lifterlms' ) ) : false;
		}

		$llms_post = $this->parse_properties_to_set( $model_array );

		if ( empty( $llms_post ) ) {
			return $wp_error ? new WP_Error( 'invalid_data', __( 'Invalid data', 'lifterlms' ) ) : false;
		}

		$update_post_properties = $this->update_post_properties( $llms_post['post'] );
		$update_meta_properties = $this->update_meta_properties( $llms_post['meta'], $allow_same_meta_value );

		$error = is_wp_error( $update_post_properties ) ? $update_post_properties : new WP_Error();
		if ( is_wp_error( $update_meta_properties ) ) {
			foreach ( $update_meta_properties->get_error_messages( 'invalid_meta' ) as $message ) {
				$error->add( 'invalid_meta', $message );
			}
		}

		if ( ! empty( $error->has_errors() ) ) {
			return $wp_error ? $error : false;
		}

		return true;

	}

Top ↑

Changelog Changelog

Changelog
Version Description
6.5.0 Introduced $allow_same_meta_value param. Code reorganization.
5.3.1 Fix quote slashing when the user is not an admin.
3.36.1 Use WP_Error::$errors in place of WP_Error::has_errors() to support WordPress version prior to 5.1.
3.34.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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