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

LifterLMS LifterLMS

  • Code Reference
  • REST API
  • LLMS-CLI

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

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

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 ↑

Related #Related

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.

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 ↑

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 ↑

User Contributed Notes #User Contributed Notes

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

© 2014 - 2023 LifterLMS · Privacy Policy · Terms and Conditions

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.