Skip to content

Instantly share code, notes, and snippets.

@pippinsplugins
Created September 3, 2014 22:02
Show Gist options
  • Save pippinsplugins/d973776836ab984aea06 to your computer and use it in GitHub Desktop.
Save pippinsplugins/d973776836ab984aea06 to your computer and use it in GitHub Desktop.
Sets an affiliate user's role to a specific role when being added as an affiliate
<?php
/*
* Plugin name: Affiliate role on registration
*/
function pw_affwp_set_role_on_registration( $affiliate_id = 0 ) {
$user_id = affwp_get_affiliate_user_id( $affiliate_id );
$user = new WP_User( $user_id );
$user->add_role( 'affiliate' );
}
add_action( 'affwp_insert_affiliate', 'pw_affwp_set_role_on_registration' );
@TheruSantana
Copy link

Very good, it worked perfectly on my site!
Is there a hook/snippet so that after the affiliate is deleted the user has the changed role as well? I want to return to the initial role state of the user before it becomes affiliated.
Regards.

@TheruSantana
Copy link

UP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment