• 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_delete_user_postmeta()

llms_delete_user_postmeta( int $user_id, int $post_id, string $meta_key = null, mixed $meta_value = null )

Delete 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

$meta_key

(string) (Optional) Meta key for lookup, if not supplied, all matching items will be removed.

Default value: null

$meta_value

(mixed) (Optional) Meta value for lookup, if not supplied, all matching items will be removed.

Default value: null


Top ↑

Return #Return

(bool) False if no postmetas has been deleted either because they do not exist or because of an error during the actual row deletion from the db. True if at least one existing user postmeta has been successfully deleted.


Top ↑

Source #Source

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

	function llms_delete_user_postmeta( $user_id, $post_id, $meta_key = null, $meta_value = null ) {

		$ret = false;

		$existing = _llms_query_user_postmeta( $user_id, $post_id, $meta_key, maybe_unserialize( $meta_value ) );
		if ( $existing ) {
			foreach ( $existing as $obj ) {
				$item = new LLMS_User_Postmeta( $obj->meta_id, false );
				if ( ! $item->delete() ) {
					$ret = $ret || false;
				} else {
					$ret = true;
				}
			}
		}

		return $ret;

	}

Expand full source code Collapse full source code View on GitHub


Top ↑

Changelog #Changelog

Changelog
Version Description
3.33.0 Returns true only if at least one existing user postmeta has been successfully deleted.
3.21.0 Introduced.

Top ↑

Related #Related

Top ↑

Uses #Uses

Uses
Uses Description
includes/models/model.llms.user.postmeta.php: LLMS_User_Postmeta::__construct()

Constructor

includes/functions/llms.functions.user.postmeta.php: _llms_query_user_postmeta()

Query user postmeta data This function is marked for internal use only.

Top ↑

Used By #Used By

Used By
Used By Description
includes/functions/llms.functions.user.postmeta.php: llms_bulk_delete_user_postmeta()

Bulk remove user postmeta data


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