• Resolved weblogik.ca

    (@solumedia)


    We created a custom field of type File named partner_logo.
    We need to display partner logo of the affiliate ID in some pages so we created a shortcode to get the affiliate logo (custom field).

    The $affiliate->get(‘partner_logo’); is always returning NULL.

    Any idea? Please help !

    function wi_render_logo_affiliate() {
    ? ? if (isset($_COOKIE['slicewp_aff'])) {
    ? ? ? ? $affiliate_id = $_COOKIE['slicewp_aff'];
    
    ? ? ? ? // Get affiliate object using the ID from the cookie
    ? ? ? ? $affiliate = slicewp_get_affiliate($affiliate_id);
    
    ? ? ? ? if (!is_null($affiliate)) {
    
    ? ? ? ? ? ? // Access properties of the affiliate object
    ? ? ? ? ? ? $affiliate_status = $affiliate->get('status');
    
    ? ? ? ? ? ? $user = get_userdata( $affiliate->get( 'user_id' ) );
    
    ? ? ? ? ? ? $affiliate_url = $user->get('website');
    
    ? ? ? ? ? ? $affiliate_logo = $affiliate->get('partner_logo');
    
    ? ? ? ? ? ? return var_dump($affiliate);
    ? ? ? ? }
    ? ? }
    ? ? return 'No affiliate';
    }

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author iova.mihai

    (@iovamihai)

    Hey @solumedia,

    Thank you for reaching out! Custom fields are not saved in the main affiliates table, but in the corresponding metadata table.

    Because of this, to grab a custom field’s value, you need to pull the affiliate meta, as follows:

    $affiliate_logo = slicewp_get_affiliate_meta( $affiliate->get( 'id ), 'partner_logo', true );

    Please try it out and let me know how it goes.

    Thank you and best wishes,

    Mihai

    • This reply was modified 1 year ago by iova.mihai.
Viewing 1 replies (of 1 total)
  • The topic ‘Get Affiliate customer field (type=file)’ is closed to new replies.