llms_get_user_postmeta( int $user_id, int $post_id, string $meta_key = null, bool $single = true, string $return = 'meta_value' )
Get user postmeta data or dates by user, post, and key.
Parameters Parameters
- $user_id
-
(int) (Required) WP User ID.
- $post_id
-
(int) (Required) WP Post ID.
- $meta_key
-
(string) (Optional) Meta key, if not supplied returns associative array of all metadata found for the given user / post.
Default value: null
- $single
-
(bool) (Optional) If true, returns only the data.
Default value: true
- $return
-
(string) (Optional) Determine if the meta value or updated date should be returned [meta_value,updated_date]. Default 'meta_value'.
Default value: 'meta_value'
Return Return
(mixed)
Source Source
File: includes/functions/llms.functions.user.postmeta.php
function llms_get_user_postmeta( $user_id, $post_id, $meta_key = null, $single = true, $return = 'meta_value' ) { $single = is_null( $meta_key ) ? false : $single; $res = array(); $metas = _llms_query_user_postmeta( $user_id, $post_id, $meta_key ); if ( count( $metas ) ) { foreach ( $metas as $meta ) { if ( $meta_key ) { $res[ $meta_key ][] = maybe_unserialize( $meta->$return ); } else { $res[ $meta->meta_key ][] = maybe_unserialize( $meta->$return ); } } } if ( $single ) { return count( $res ) ? $res[ $meta_key ][0] : ''; } elseif ( $meta_key ) { return count( $res ) ? $res[ $meta_key ] : array(); } return $res; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.21.0 | Introduced. |