WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a site where I'd like anyone to be able to sign up, but people who sign up with an invite code would automatically be promoted to a role with more privileges.

I'm aware that there are plugins that handle invite codes, but so far I haven't found any that will do quite this.

For my purposes, one invite code used by many people would work best. I'd be sending out the invite code to a mailing list, and I'm not that concerned about limiting access.

share|improve this question
up vote 0 down vote accepted

This is one way to do it

add_action('user_register', 'set_custom_default_role')
function set_custom_default_role($user_id) {
    // Maybe get available referral codes from database & compare them against the one available
    if(true) {
        $user = new WP_User( $user_id );
share|improve this answer
Thanks, that gives me some ideas. I think in combination with this tutorial (blog.ashfame.com/2010/11/…), I can make it work. – Adam Rice Oct 20 '12 at 23:14

Try http://wordpress.org/extend/plugins/cm-invitation-codes/ Cm Invitation Code. You can combine it together with Whishlist Member and assign for each new user it's role based on his invitation code

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.