• LifterLMS
  • Knowledge Base
  • Academy
  • Blog
  • Podcast
  • Contributors

LifterLMS LifterLMS

Code Reference

  • Home
  • Code Reference
Skip to content
Filter by type:
Search
Browse: Home / Code Reference / Functions / llms_bulk_update_user_postmeta()

llms_bulk_update_user_postmeta( int $user_id, int $post_id, array $data = array(), bool $unique = true )

Update bulk update user postmeta data

Contents

  • Description
    • Parameters
    • Return
    • Source
    • Changelog
  • Related
    • Uses
    • Used By
  • User Contributed Notes

Description #Description


Parameters #Parameters

$user_id

(int) (Required) WP User ID

$post_id

(int) (Required) WP Post ID

$data

(array) (Optional) key=>val associative array of meta keys => meta values to update/add

Default value: array()

$unique

(bool) (Optional) if true, updates existing value (if it exists) if false, will add a new record (allowing multiple records with the same key to exist)

Default value: true


Top ↑

Return #Return

(array|true) on error returns an associative array of the submitted keys, each item will be true for success or false for error on success returns true


Top ↑

Source #Source

File: includes/functions/llms.functions.user.postmeta.php

	function llms_bulk_update_user_postmeta( $user_id, $post_id, $data = array(), $unique = true ) {

		$res = array_fill_keys( array_keys( $data ), null );
		$err = false;
		foreach ( $data as $key => $val ) {
			$update = llms_update_user_postmeta( $user_id, $post_id, $key, $val, $unique );
			$res[ $key ] = $update;
			if ( ! $update ) {
				$err = true;
			}
		}

		return $err ? $res : true;

	}

Expand full source code Collapse full source code View on GitHub


Top ↑

Changelog #Changelog

Changelog
Version Description
3.21.0 Introduced.

Top ↑

Related #Related

Top ↑

Uses #Uses

Uses
Uses Description
includes/functions/llms.functions.user.postmeta.php: llms_update_user_postmeta()

Update user postmeta data

Top ↑

Used By #Used By

Used By
Used By Description
includes/models/model.llms.student.php: LLMS_Student::insert_completion_postmeta()

Add student postmeta data for completion of a lesson, section, course or track

includes/models/model.llms.student.php: LLMS_Student::insert_enrollment_postmeta()

Add student postmeta data for enrollment into a course or membership


Top ↑

User Contributed Notes #User Contributed Notes

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





Permalink:
© 2014 - 2019 LifterLMS · Privacy Policy · Terms and Conditions