Skip to content

Instantly share code, notes, and snippets.

@ucheng
Created April 28, 2020 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ucheng/cf7f88d3b0c56ab0f7b620fd325233a3 to your computer and use it in GitHub Desktop.
Save ucheng/cf7f88d3b0c56ab0f7b620fd325233a3 to your computer and use it in GitHub Desktop.
show customer linked affiliate
<?php
add_action('show_user_profile', 'mys_additional_profile_fields', 9);
add_action('edit_user_profile', 'mys_additional_profile_fields', 9);
function mys_additional_profile_fields($user)
{
echo '<h2>連結的推薦人</h2>';
$customer = affwp_get_customer($user->user_email);
$linked_affiliate_id = affwp_get_customer_meta($customer->customer_id, 'affiliate_id');
if (!empty($linked_affiliate_id) && $linked_affiliate_id[0]) {
$user_id = affwp_get_affiliate_user_id($linked_affiliate_id[0]);
$user_info = get_userdata($user_id);
$link = get_edit_user_link($user_id);
echo '<a href="' . $link . '">' . $user_info->display_name . '(' . $user_info->user_email . ')</a>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment