LLMS_Person::get_user_postmetas_by_key( $user_id,  $meta_key )

Return array of objects containing user meta data for a single post.


Description Description


Return Return

(array)


Top ↑

Source Source

File: includes/class.llms.person.php

	public function get_user_postmetas_by_key( $user_id, $meta_key ) {
		global $wpdb;

		if ( empty( $user_id ) || empty( $meta_key ) ) {
			return;
		}

		$table_name = $wpdb->prefix . 'lifterlms_user_postmeta';

		$results = $wpdb->get_results( $wpdb->prepare(
		'SELECT * FROM ' . $table_name . ' WHERE user_id = %s and meta_key = "%s" ORDER BY updated_date DESC', $user_id, $meta_key ) );

		if ( empty( $results ) ) {
			return;
		}

		for ( $i = 0; $i < count( $results ); $i++ ) {
			$results[ $results[ $i ]->post_id ] = $results[ $i ];
			unset( $results[ $i ] );
		}

		return $results;
	}

Top ↑

User Contributed Notes User Contributed Notes

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