• 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_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 This function is marked for internal use only.

Contents

  • Description
    • Parameters
    • Return
    • Source
    • Changelog
  • Related
    • 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

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 ) : '';

		$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
		) );

			return $res;

	}

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 ↑

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 ↑

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