I want to ban people or limit registering on unique national ID (You can think it as 11 digit number). Is there any plugin or a code snippet you know? Site will based on MultiSite + BuddyPress.

Update: I am not looking for IP ban. You can think it like phone number.. And every user must have 1 unique phone number and i need to ban that phone number if need.

(Sorry for bad english)


Not sure if this is want you are looking for, but one approach could be hiding the registration altogether for all user, but the users from countries and territories you need. Here is a plugin I've been checking out myself, but I must admit, I haven't used it on a production site yet. It looks solid, though:



Put something along the lines of this in functions.php or a plugin. It may need some tweaking and modification, it's not intended as an 'as is' example, but it should put you on the right path.

The following adds a new field UI to the default registration form, and then checks if its 11 characters long, and that no other user has the same UID. It stores the UID in the users meta data.

If you have a custom registration form, a text input with the name 'user_uid' will suffice, and to grab the uid of a user, use: $uid = get_the_author_meta( 'user_uid', $user->ID );

Example as follows:


add_action('user_register', 'register_extra_fields');

function show_uid_field(){
        <label>Unique ID<br />
        <input id="user_uid" class="input" type="text" tabindex="20" size="25" value="<?php echo $_POST['user_uid']; ?>" name="first"/>

function check_fields($login, $email, $errors) {
    global $user_uid;
    if ($_POST['user_uid'] == '') {
        $errors->add('empty_user_uid', "<strong>ERROR</strong>: Please Enter your UID");
    } else {
        $user_uid = $_POST['user_uid'];
        if(strlen(trim($user_uid)) != 11){
            $errors->add('invalid_user_uid', "<strong>ERROR</strong>: Invalid value, please Enter your UID");
        } else {
            $szSort = "user_nicename";
            $aUsersID = $wpdb->get_col( $wpdb->prepare( "SELECT $wpdb->users.ID FROM $wpdb->users ORDER BY %s ASC", $szSort ));
            foreach ( $aUsersID as $iUserID ) {
                $user = get_userdata( $iUserID );
                $uid = get_the_author_meta( 'user_uid', $user->ID );
                if($uid == $user_uid){
                    $errors->add('notunique_user_uid', "<strong>ERROR</strong>: This UID is already taken, please enter your UID");
            // do your soap check here

function register_extra_fields($user_id, $password="", $meta=array())  {
    update_usermeta( $user_id, 'user_uid', $_POST['user_uid'] );


I would also note that while gravity forms is great, if your trying to extend it your in for a world of pain.


When user registers to your site, have the number stored as a unique key (similar to how user names are handled)..

So create a new text field on the registration form that handles this number and updates usermeta upon success.

If you need to ban that account for any reason then in your ban function you will need to move that id number into a seperate custom table in your database.

So basically you need another check on registration that looks for a match in your custom table for banned id numbers and also a check for existing id numbers (not banned) if there is a match here then the registration process will fail. If no match then it is processed..

But how are you going to verify that people are using original government generated id numbers?.. for this you will have to have access to the formula for generating these id's and then need to create an algorythm to check for validaty.


OK, so from what I can tell, you want to require an official National ID during the registration process (which you will query for validity against the SOAP service you mentioned)

So, you need to add a field to the user profile to store the National ID, then hook the registration process to display this new field and require entry.

There's a good example of how to do this here: http://tipsforwordpress.com/wordpress/add-custom-field-to-register-form/comment-page-1/#comment-152 (You'll need to add in the SOAP call and failure path)


first of all, thanks a lot for every answer and everyone who thought a solution for this.

my best possible solution without changing too much thing:

As i said in a comment, i will use http://www.gravityforms.com/add-ons/user-registration/ for registering. This plugin working even you disable wordpress user registeration. So i will disable user registeration and this plugin's form will be only way to register to this site. Critical option in there was "No Duplicates". I will select "No Duplicates" for this number input so plugin will use its previous form data for not letting 2 registeration with this number. So if i want to ban someone, i can just ban him with normal wordpress banning system and he cant register twice so problem is solved imo.

And again thanks a lot for trying to help :) Note: I am not doing adversitement or anything, just sharing my solution so i hope its ok.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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