Username Validation
-
Hi, I am not entirely sure if this should be posted on the wordpress forums or here. I think that since this PHP script is using data in the buddypress registration page, that here is the place.
Anyway, I am trying to set up a website for my Minecraft Server that I have been hosting for the past few months. I am using the code below to only allow players with a premium Minecraft account to register on the website, in order to block spammers. The link in the code (http://www.minecraft.net/haspaid.jsp?user=) will print a boolean changing if the account name is valid or not. The name is put after the “=” and if it is valid, “true” will be printed, and if it isn’t valid “false” will be printed.
I am trying to make it that the name is checked before the account is made. What should happen is that the username is taken and checked on the Minecraft database, and allow the user to register if “true” is echoed, and if “false” is echoed, the registration will not be allowed to continue.
The issue is, that I am really not skilled in PHP at all, and I can’t find out why this code isn’t working. It makes no visible change to anything, and registration continues as if it wasn’t there. If anyone could give me a hand here, that would be great. Here is my Code.
<?php /* Plugin Name: Minecraft Username Validator Description: Minecraft username Validation Version: 0.1 Author: JeremyPark123999 */ /* Register actions */ add_action('registration_errors', 'verify_mc_account', 10, 3); add_action('admin_menu', 'add_mcval_options'); /* Check account on minecraft.net */ function verify_mc_account( $errors, $login, $email ) { //$user_info = get_userdata(1); $user_info = get_user_by('login', $login ); $options = array( 'timeout' => 5, ); $mcacct = wp_remote_get('http://www.minecraft.net/haspaid.jsp?user='.$user_info->user_login); if ( $mcacct == 'false' ) { if ( $mcacct == 'false' ) { $errors->add('mc_error',__('<strong>ERROR:</strong> Minecraft account is invalid.')); } else { $errors->add('mc_error',__('<strong>ERROR:</strong> Unable to contact minecraft.net.')); } } return $errors; } /* Activation/Deactivation */ function set_mcval_options() { add_option('hide_me', 'false'); } function unset_mcval_options() { delete_option('hide_me'); } register_activation_hook(__FILE__, 'set_mcval_options'); register_deactivation_hook(__FILE__, 'unset_mcval_options'); /* Add admin menu */ function add_mcval_options() { if ( get_option('hide_me') != "true" ) { add_options_page('Minecraft Validator Options', 'Minecraft Validator', 8, 'mcval-options', 'mcval_options'); } } /* Display options page */ function mcval_options() { ?> <?php }
My website is at tumbleweed-mc.net
- The topic ‘Username Validation’ is closed to new replies.