Shortcode for affiliates permanent my users on front end

I have used code developed by Antonio B and previously on this forum, thank you.

I wish to display my affiliate permanent my users on the front end so the affiliate can see a list of ‘users’ registered on the program. The shortcode works and displays the user_login or the display_name meta – my issue is that the list of my users returned does not match the registered users by the affiliate. I do not have the skill to resolve and attempting to get a freelancer but no luck on understanding of this functionality. Very useful short code if I can get it to work for me as it reassures my affiliates that we have received and registered their ‘my users’ but these ‘my users’ may not have purchased yet.

affiliates_permanent_my_users


Comments

3 responses to “Shortcode for affiliates permanent my users on front end”

  1. That’s great Stephen! 🙂

  2. Thanks George, works well the shortcode [affiliates_permanent_my_users] I appreciate the effort, gives my affiliates loads of visibility.

    Regards
    Steve

  3. Hi Stephen,

    Try with the updated version we prepared.
    First, delete the old block from your functions.php file and then add the snippet below.

    function my_affiliates_permanent_my_users( $atts ){
    $output = "";
    if ( is_user_logged_in() ) {
    $user = wp_get_current_user();
    if ( null !== ( affiliates_get_user_affiliate( $user->ID ) ) ) {
    $affiliate_id = affiliates_get_user_affiliate( $user->ID );

    $args = array(
    'meta_key' => Affiliates_Permanent::REFERRER,
    'meta_value' => $affiliate_id
    );
    $users = get_users( $args );
    }

    if ( isset( $users ) && ( sizeof( $users ) > 0 ) ) {
    $output .= '';
    foreach ( $users as $us ) {
    $output .= '' . $us->data->user_login . '';
    }
    $output .= '';
    }
    }

    return $output;
    }
    add_shortcode( 'affiliates_permanent_my_users', 'my_affiliates_permanent_my_users' );

    The shortcode [affiliates_permanent_my_users] will display the referred users’ user_login for the affiliate who logged in. If it doesn’t display anything, then the affiliate has not yet referred anyone.

    Kind regards,
    George

Share