Title: Approval / Invitation / Access code? (wp-register.php)
Last modified: August 18, 2016

---

# Approval / Invitation / Access code? (wp-register.php)

 *  Resolved [narakalex](https://wordpress.org/support/users/narakalex/)
 * (@narakalex)
 * [20 years, 10 months ago](https://wordpress.org/support/topic/approval-invitation-access-code-wp-registerphp-1/)
 * When people click on “register” there is only 2 options..
    enter username: enter
   email:
 * how can i add a simple 3 option? like “invitation” code?
    I’d like only my friends&
   relatives to be able to register and make comments to my blog. I’d like to be
   able to give out 1 or 2 invitation codes (like for example: “wordpressrules” 
   or “wp2005”). So when people click “register” is will ask for 3 things enter 
   username: enter email: enter invitationcode:
 * How to come about this?
 * ***** This is my attempt to make it in wp-register.php*****
    case ‘register’:
 * $user_login = $_POST[‘user_login’];
    $user_email = $_POST[‘user_email’]; $invitationcode
   = $_POST[‘invitationcode’];
 * /* checking that username has been typed */
    if ($user_login == ”) { die (__(‘
   ERROR: Please enter a username.’)); }
 * /* checking e-mail address */
    if ($user_email == ”) { die (__(‘ERROR: Please
   type your e-mail address.’)); } else if (!is_email($user_email)) { die (__(‘ERROR:
   The email address isnâ€™t correct.’)); } if ($invitationcode,’wp2005′) != ‘wp2005’)
   die (__(‘ # You must enter your invitationcode in the last box (below email)’));
 * *****
    PS. I don’t know how to code in php.. i can barely make a system-out-print
   with hello world…

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [skippy](https://wordpress.org/support/users/skippy/)
 * (@skippy)
 * [20 years, 10 months ago](https://wordpress.org/support/topic/approval-invitation-access-code-wp-registerphp-1/#post-244996)
 * `<?php
    if ($invitationcode != 'wp2005') { die (__('ERROR: You must enter your
   invitation code in the last box (below email)')); } ?>
 *  Thread Starter [narakalex](https://wordpress.org/support/users/narakalex/)
 * (@narakalex)
 * [20 years, 10 months ago](https://wordpress.org/support/topic/approval-invitation-access-code-wp-registerphp-1/#post-245075)
 * Super duper (it works..)!!
 * For Complete Solution.. see post below….
    Simply Copy & Paste & Replace the code
   in your wp-register.php
 *  Thread Starter [narakalex](https://wordpress.org/support/users/narakalex/)
 * (@narakalex)
 * [20 years, 10 months ago](https://wordpress.org/support/topic/approval-invitation-access-code-wp-registerphp-1/#post-245078)
 * Here’s the complete solution (with 99.999% going to Skippy..)
 * Open wp-register.php
 * case ‘register’:
    $user_login = $_POST[‘user_login’]; $user_email = $_POST[‘user_email’];
   $invitationcode = $_POST[‘invitationcode’]; /*Added*/
 *  /* checking that username has been typed */
    if ($user_login == ”) { die (__(‘**
   ERROR**: Please enter a username.’)); }
 * /* This defines the invitation… type 1 or more invitationcodes*/
    if (($invitationcode!
   = ‘wp2005’) && ($invitationcode != ‘wprules’)) { die (__(‘ERROR: You must enter
   your invitation code in the last box or you have typed a wrong invitationcode.’));}
 * **Goto**
 * <form method=”post” action=”wp-register.php” id=”registerform”>
 * <input type=”hidden” name=”action” value=”register” />
 * <label for=”user_login”><?php _e(‘Username:’) ?></label>
 * <input type=”text” name=”user_login” id=”user_login” size=”20″ maxlength=”20″/
   >
 * <label for=”user_email”><?php _e(‘E-mail:’) ?></label>
    <input type=”text” name
   =”user_email” id=”user_email” size=”25″ maxlength=”100″ /> A password will be
   emailed to you.
 * <label for=”invitationcode”><?php _e(‘Invitationcode:’) ?></label>
    <input type
   =”text” name=”invitationcode” id=”invitationcode” size=”25″ maxlength=”100″ /
   >
 * <p class=”submit”><input type=”submit” value=”<?php _e(‘Register’) ?> Â»” id=”
   submit” name=”submit” />
 *  [Nicki Faulk](https://wordpress.org/support/users/nitallica/)
 * (@nitallica)
 * [20 years, 9 months ago](https://wordpress.org/support/topic/approval-invitation-access-code-wp-registerphp-1/#post-245880)
 * You know, I came on this morning looking for a way to blacklist registrations
   by email or IP … but I like this way better. Thanks for posting this! 😀
 *  [gwaldecker](https://wordpress.org/support/users/gwaldecker/)
 * (@gwaldecker)
 * [20 years, 8 months ago](https://wordpress.org/support/topic/approval-invitation-access-code-wp-registerphp-1/#post-245943)
 * Thanks for this great idea. Being new to this, I’m not sure how much of the code
   in wp-register.php to replace. It sounds like you mean all of it. This is the
   first part of what my wp-register.php looks like:
 * <?php
    require(‘./wp-config.php’);
 * $wpvarstoreset = array(‘action’);
    for ($i=0; $i<count($wpvarstoreset); $i +=
   1) { $wpvar = $wpvarstoreset[$i]; if (!isset($$wpvar)) { if (empty($_POST[“$wpvar”])){
   if (empty($_GET[“$wpvar”])) { $$wpvar = ”; } else { $$wpvar = $_GET[“$wpvar”];}}
   else { $$wpvar = $_POST[“$wpvar”]; } } }
 * if ( !get_settings(‘users_can_register’) )
    $action = ‘disabled’;
 * header( ‘Content-Type: ‘ . get_bloginfo(‘html_type’) . ‘; charset=’ . get_bloginfo(‘
   charset’) );
 * switch($action) {
 * case ‘register’:
 *  $user_login = $_POST[‘user_login’];
    $user_email = $_POST[‘user_email’];
 *  /* checking that username has been typed */
    if ($user_login == ”) { die (__(‘**
   ERROR**: Please enter a username.’)); }
 *  /* checking e-mail address */
    if ($user_email == ”) { die (__(‘**ERROR**: Please
   type your e-mail address.’)); } else if (!is_email($user_email)) { die (__(‘**
   ERROR**: The email address isn’t correct.’)); }
 *  /* checking the username isn’t already used by another user */
    $result = $wpdb-
   >get_results(“SELECT user_login FROM $wpdb->users WHERE user_login = ‘$user_login'”);
   if (count($result) >= 1) { die (__(‘**ERROR**: This username is already registered,
   please choose another one.’)); }
 * It continues…. So how much of this do I replace? Thanks.
 *  [gregsbaby64](https://wordpress.org/support/users/gregsbaby64/)
 * (@gregsbaby64)
 * [20 years, 8 months ago](https://wordpress.org/support/topic/approval-invitation-access-code-wp-registerphp-1/#post-245948)
 * Sweet, thank you! 🙂

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Approval / Invitation / Access code? (wp-register.php)’ is closed to 
new replies.

## Tags

 * [approval](https://wordpress.org/support/topic-tag/approval/)
 * [Invitation](https://wordpress.org/support/topic-tag/invitation/)

 * 6 replies
 * 5 participants
 * Last reply from: [gregsbaby64](https://wordpress.org/support/users/gregsbaby64/)
 * Last activity: [20 years, 8 months ago](https://wordpress.org/support/topic/approval-invitation-access-code-wp-registerphp-1/#post-245948)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
