Last active
July 4, 2016 19:30
-
-
Save amdrew/238913508f8ae2da663f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* [affiliate_referral_url_username] shortcode | |
*/ | |
function affwp_custom_referral_url_shortcode( $atts, $content = null ) { | |
if ( ! affwp_is_affiliate() ) { | |
return; | |
} | |
shortcode_atts( array( | |
'url' => '' | |
), $atts, 'affiliate_referral_url_username' ); | |
if ( ! empty( $content ) ) { | |
$base = $content; | |
} else { | |
$base = ! empty( $atts[ 'url' ] ) ? $atts[ 'url' ] : home_url( '/' ); | |
} | |
$affiliate = affwp_get_affiliate( affwp_get_affiliate_id() ); | |
$user_info = get_userdata( $affiliate->user_id ); | |
$affiliate_user_name = $user_info->user_login; | |
return add_query_arg( affiliate_wp()->tracking->get_referral_var(), $affiliate_user_name, $base ); | |
} | |
add_shortcode( 'affiliate_referral_url_username', 'affwp_custom_referral_url_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment