Since there have been several requests for an example on how to record a referral when an affiliate’s visitor has registered for an account, I’ve written an example plugin Affiliates Members which does just that.
1. Back-up your site and database.
2. Install and active the Affiliates plugin if you haven’t already.
3. Download the Affiliates Members example plugin, decompress the content and place it (a single file called affiliates-members.php) in your wp-content/plugins folder and then activate the plugin.
Now whenever a new user registers on your site, a referral will be recorded showing the new user’s name.
It’s a basic example on how to track sign-up referrals, so don’t expect more of it than just recording the new user’s name and other default data but this may actually be just enough for quite a few … comments, questions and intense cheers are, of course, welcome.
For those interested in how this works without wanting to bother with installing the example plugin, this is how it’s done:
add_action( 'user_register', 'affiliates_members_user_register' );
function affiliates_members_user_register( $user_id ) {
if ( function_exists( 'affiliates_suggest_referral' ) ) {
$userdata = get_userdata( $user_id );
$data = array(
'user-name' => array(
'title' => 'Username',
'domain' => 'affiliates-members',
'value' => $userdata->display_name,
)
);
affiliates_suggest_referral( get_the_ID(), __( 'New member', 'affiliates-members' ), $data );
}
}
Leave a Reply