WordPress Affiliate Manager

Affiliates Management Plugin for WordPress

  • Home
  • Features
    • Screen Shots
  • Download
  • Documentation
  • Addons
  • Support
    • Support Forum
    • Forum Login
    • Forum Registration
    • Contact
    • Premium Addon/Plugin Support

[Resolved] Get current logged in affiliate.id

by

WordPress Affiliate Manager › Forums › Affiliate Manager Plugin › Get current logged in affiliate.id

  • This topic has 2 replies, 2 voices, and was last updated 4 years, 7 months ago by nightfreak.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • November 19, 2020 at 11:28 pm #7064
    nightfreak
    Participant

    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

    November 20, 2020 at 5:17 am #7066
    Shadow Labs
    Keymaster

    @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
        )
    );
    
    November 20, 2020 at 8:35 am #7067
    nightfreak
    Participant

    Thank you! This works

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Log In

Featured Addons

  • WooCommerce Coupon Tracking
  • WooCommerce Product Specific Commission

Copyright © 2025 | WordPress Affiliate Manager | Privacy Policy