Affiliate Profile Picture Integration

Posted in

Somehow I need to integrate an upload field for affiliates to display their profile picture which needs to be generated by shortcode. If there was someway to just have the affiliates facebook profile image display based on their profile url that would be good also but I think that might be too difficult to do.

What can you recommend me for this issue?

How can I pull this off?

Thanks

10 Responses to Affiliate Profile Picture Integration

  1. George June 19, 2017 at 8:23 am #

    Hi Derek,

    The easiest way to implement would be with a shortcode by using the get_avatar(…) function. This would display the same way as it is displayed in the user profile page.

    Kind regards,
    George

  2. Derek June 19, 2017 at 1:19 pm #

    Hi,

    Yeah I could just use a simple plugin to display an avatar with a shortcode but I need the avatar displayed to be the avatar of the affiliate who is the referrer. Like I’ve just clicked an affiliate link and it directs me to the website displaying my referrer along with the avatar of that affiliate. So how do I tie get avatar to affiliate id?

    Thanks

  3. George June 19, 2017 at 5:04 pm #

    I see.

    You can get the user_id with affiliates_get_affiliate_user and then retrieve the avatar for that user.

    Cheers,
    George

  4. Derek June 23, 2017 at 4:49 am #

    Hey George,

    I’ve still not succeeded in making this work. Here’s what I’ve tried.

    add_action( ‘init’, ‘show_affiliate_info’ );
    function show_affiliate_info( $data) {

    $pretext = “You come referred by “;
    if ( !is_admin() ) {
    if (!class_exists(“Affiliates_Service”))
    include_once( AFFILIATES_CORE_LIB . ‘/class-affiliates-service.php’ );

    $affiliate_id = Affiliates_Service::get_referrer_id();

    if ( $affiliate_id ) {
    if ( $affiliate_id !== affiliates_get_direct_id() ) {
    if ( $user_id = affiliates_get_affiliate_user( $affiliate_id ) ) {
    if ( $user = get_user_by( ‘id’, $user_id ) ) {
    echo get_avatar( $id_or_email, affiliate_id);
    }
    }
    }
    }
    }
    }

    But it sort of breaks things. I’m not great at php stuff. So I’m wondering how much I have to pay you guys to make this work for me? Let me know about that.

    Thanks

  5. George June 23, 2017 at 9:56 am #

    Thanks for sharing Derek, i will have a look at this and post an updated version of this.

    Cheers,
    George

  6. George June 23, 2017 at 1:25 pm #

    Hi Derek,

    I modified slightly your snippet and made it a shortcode.
    You can find it at Referring Affiliate’s Avatar – example shortcode and you can use it if you place [referring-affiliate-avatar] in your affiliate area page, preferably enclosed in the shortcode block [affiliates_is_affiliate]…[/affiliates_is_affiliate]

    Cheers,
    George

  7. Derek June 23, 2017 at 6:19 pm #

    Hey George,

    Really appreciate you looking into that for me. So close to having everything right where I need it.
    I made tiny images that you could click and then tied them to custom profile fields urls which would allow the viewer to click them and take them to social media profiles of the affiliate. Those no longer work in conjunction with the new avatar.
    If I use a shortcode with a link it kills the avatar code. Is there another way I can wrap this so that doesn’t happen? I tried single and double quotes but maybe you know a trick? This was all working until I added the avatar.

    Example:

    Thanks

  8. Derek June 23, 2017 at 6:24 pm #

    Example:

    target=’_blank’ href=”[referrer display='facebook_url']“><img src="https://instantpaybtc.com/wp-content/uploads/2017/06/social-facebook-circle-128.png&quot; class="socialuser"

  9. Derek June 24, 2017 at 8:20 am #

    Just an update on this. I managed to get it to work with your code. Gravatar images are only 96px wide though and a better alternative would be for the affiliate to actually be allowed to upload an image and then have that display. I’ll try to come up with something but excellent job George. Really appreciate your time.
    Thanks

  10. George June 26, 2017 at 7:26 am #

    Hi Derek,

    Whether you decide to let users upload images or display their facebook image with a link attribute to the shortcode, you have to sanitize the image itself. You will have to check for example whether the image shows a face and not something prohibited.

    Another idea i have, check if there is any plugin that can connect your site to facebook and provides also a shortcode to display user profile picture anywhere you like. That way you can easily modify an existing shortcode and make it work for the referrer instead of the logged in user.

    Cheers