- This topic has 2 replies, 2 voices, and was last updated 4 years, 7 months ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.
Affiliates Management Plugin for WordPress
by
WordPress Affiliate Manager › Forums › Affiliate Manager Plugin › Get current logged in affiliate.id
Hello,
my affiliates want to see also pending orders in the “Sales” section after the login, not only the completed orders, so I want to add a second table under the confirmed transactions table.
I’m adding this code in /html/transaction_table.php to get the incomplete orders:
global $wpdb;
$query = $wpdb->get_results("
SELECT p.ID, p.post_date, d2.meta_value amount, p.post_status status
FROM wp_posts p
INNER JOIN wp_postmeta d1 ON d1.post_id = p.ID AND d1.meta_key = '_wpam_id' AND d1.meta_value = 14
INNER JOIN wp_postmeta d2 ON d2.post_id = p.ID AND d2.meta_key = '_order_total'
WHERE p.post_status <> 'wc-completed' AND p.post_status <> 'trash'
ORDER BY p.post_date DESC
");
It works good, but I need to get the current logged in affiliate_id to only show his transactions.
Can someone help me how to get the affiliate_id in the “Sales” section?
Thanks,
Chris
@nightfreak, You can try this:
$user_id = get_current_user_id();
global $wpdb;
$affiliate_id = $wpdb->get_var(
$wpdb->prepare(
"
SELECT affiliateId
FROM ".WPAM_AFFILIATES_TBL."
WHERE userId = %d
AND status = 'active'
",
$user_id
)
);
Thank you! This works