• Resolved narakalex

    (@narakalex)


    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 isna€?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)
  • <?php
    if ($invitationcode != 'wp2005') {
    die (__('ERROR: You must enter your invitation code in the last box (below email)'));
    }
    ?>

    Thread Starter narakalex

    (@narakalex)

    Super duper (it works..)!!

    For Complete Solution.. see post below….
    Simply Copy & Paste & Replace the code in your wp-register.php

    Thread Starter narakalex

    (@narakalex)

    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” />

    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! ??

    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.

    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.