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

Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

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

Query user postmeta data.

Contents

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

Description #Description

This function is marked for internal use only.


Top ↑

Parameters #Parameters

$user_id

(int) (Required) WP User ID.

$post_id

(int) (Required) WP Post ID.

$meta_key

(string) (Optional) Meta key.

Default value: null

$meta_value

(string) (Optional) Meta value.

Default value: null


Top ↑

Return #Return

(array)


Top ↑

Source #Source

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

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

		global $wpdb;

		$key = $meta_key ? $wpdb->prepare( 'AND meta_key = %s', $meta_key ) : '';
		$val = $meta_value ? $wpdb->prepare( 'AND meta_value = %s', $meta_value ) : '';

		// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
		$res = $wpdb->get_results(
			$wpdb->prepare(
				"SELECT * FROM {$wpdb->prefix}lifterlms_user_postmeta
				 WHERE user_id = %d AND post_id = %d {$key} {$val} ORDER BY updated_date DESC",
				$user_id,
				$post_id
			)
		);
		// phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared

		return $res;

	}

Expand full source code Collapse full source code View on GitHub


Top ↑

Related #Related

Used By #Used By

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

Delete user postmeta data.

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

Get user postmeta data or dates by user, post, and key.

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

Update user postmeta data.


Top ↑

Changelog #Changelog

Changelog
Version Description
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.