llms_locate_order_for_user_and_plan( int $user_id, int $plan_id )
Find an existing order for a given plan by a given user.
Parameters Parameters
- $user_id
-
(int) (Required) The WP_User ID.
- $plan_id
-
(int) (Required) The Access Plan post ID.
Return Return
(mixed) null if no order found, WP_Post ID as an int if found
Source Source
File: includes/functions/llms.functions.order.php
function llms_locate_order_for_user_and_plan( $user_id, $plan_id ) {
global $wpdb;
// Query.
$id = $wpdb->get_var(
$wpdb->prepare(
"SELECT ID FROM {$wpdb->prefix}posts AS p
JOIN {$wpdb->prefix}postmeta AS pm_user ON pm_user.post_id = p.ID AND pm_user.meta_key = '_llms_user_id'
JOIN {$wpdb->prefix}postmeta AS pm_plan ON pm_plan.post_id = p.ID AND pm_plan.meta_key = '_llms_plan_id'
WHERE p.post_type = 'llms_order'
AND pm_user.meta_value = %d
AND pm_plan.meta_value = %d
;",
$user_id,
$plan_id
)
); // db-cache ok.
// Return an int not a numeric string.
return $id ? absint( $id ) : $id;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 3.30.1 | Introduced. |