Created
July 22, 2014 08:49
-
-
Save gabrielmerovingi/31cf7412f19859b6dabd to your computer and use it in GitHub Desktop.
Basic examples of inserting a users affiliate ID in their WordPress or bbPress profiles.
This file contains 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
/** | |
* Show Affiliate ID | |
* Inserts the displayed users affiliate ID | |
* in their bbPress profile. | |
* @version 1.0 | |
*/ | |
add_action( 'bbp_template_after_user_profile', 'mycred_pro_show_affiliate_id_in_bbp_profile' ); | |
function mycred_pro_show_affiliate_id_in_bbp_profile() { | |
$user_id = bbp_get_displayed_user_id(); | |
$affiliate_link = get_user_meta( $user_id, 'mycred_affiliate_link', true ); | |
if ( $affiliate_link != '' ) { ?> | |
<div class="bbp-user-profile"> | |
<p>Your Affiliate ID: <?php echo $affiliate_link; ?></p> | |
</div> | |
<?php | |
} | |
} | |
/** | |
* Show Affiliate ID | |
* Insert the users affiliate ID in | |
* their WordPress profile. | |
* @version 1.0 | |
*/ | |
add_action( 'personal_options', 'mycred_pro_show_affiliate_id_in_wp_profile' ); | |
function mycred_pro_show_affiliate_id_in_wp_profile( $user ) { | |
$affiliate_link = get_user_meta( $user->ID, 'mycred_affiliate_link', true ); | |
if ( $affiliate_link != '' ) { ?> | |
<tr> | |
<th scope="row">Your Affiliate ID</th> | |
<td><h2 style="margin:0;padding:0;"><?php echo $affiliate_link; ?></h2></td> | |
</tr> | |
<?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment