Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8333477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:02:46+00:00 2026-06-09T03:02:46+00:00

So I’m working on my login page modification again… and I’m running into another

  • 0

So I’m working on my login page modification again… and I’m running into another issue. Here’s the scenario… I’ve got a plugin that consists of two components: a script that rewrites the username field on the login/registration form, and a function that overrides the validation handler on registration.

Here are the files in question…

validator.php

<?php
// Rewrite registration form
function mpm_registration_form() {
    wp_enqueue_script('login_form', plugin_dir_url(__FILE__).'js/usernamerewrite.js', array('jquery'), false, false);
}
add_action('login_head', 'mpm_registration_form');

// Register actions
add_action('register_post', 'mpm_validator_verify_account', 10, 3);

// Check username against minecraft.net database
function mpm_validator_verify_account($login, $email, $errors) {
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_URL, 'http://www.minecraft.net/haspaid.jsp?user='.rawurlencode($login));
    $mcacct = curl_exec($curl);
    curl_close($curl);

    if($mcacct != 'true') {
        if($mcacct == 'false') {
            $errors->add('mc_error', __('<strong>Error:</strong> Minecraft account is invalid.'));
            return $errors;
        } else {
            $errors->add('mc_error', __('<strong>Error:</strong> Unable to contact minecraft.net.'));
            return $errors;
        }
        add_filter('registration_errors', 'mpm_validator_verify_account', 10, 3);
    }
}

js/usernamerewrite.js

jQuery(document).ready(function ($) {
    'use strict';
    /*global document: false */
    /*global $, jQuery */
    var username, reset;
    if ($('body').hasClass('login')) {
        username = document.createElement("input");
        username.type = 'text';
        username.name = 'log';
        username.id = 'user_login';
        username.className = 'input';
        username.size = '20';
        username.tabIndex = '10';
        reset = document.createElement("input");
        reset.type = 'text';
        reset.name = 'user_login';
        reset.id = 'user_login';
        reset.className = 'input';
        reset.size = '20';
        reset.tabIndex = '10';
        $('label').each(
            function () {
                if ($(this).text().trim() === 'Username') {
                    $(this).html('Minecraft Username<br/>');
                    $(this).append(username);
                } else if ($(this).text().trim() === 'Username or E-mail:') {
                    $(this).html('Minecraft Username or E-mail:<br/>');
                    $(this).append(reset);
                }
            }
        );
    }
});

The problem is that if I write the wp_enqueue_script line as it currently is (with the script being loaded in the header), the action function is handled properly but the rewrite never happens. Conversely, if I change it such that the script is loaded in the footer, the rewrite occurs, but the action is no longer handled properly (the username field is reset prior to being submitted). I’m at a complete loss.

Second (minor) annoyance: There is always a slight delay between the page loading and the occurrence of the rewrite. Any thoughts on how to make this more transparent would be greatly appreciated.

EDIT: If you’re going to vote the question down, the least you could do is indicate why…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:02:47+00:00Added an answer on June 9, 2026 at 3:02 am

    Finally figured it out! The way I was doing it was horrible… I really need to brush up on my JS/jQuery. Here’s what I’ve ended up with which works beautifully in all my test cases, and also rewrites not just the field labels, but messages as well…

    jQuery(document).ready(function ($) {
    'use strict';
    /*global document: false */
    /*global $, jQuery */
        $('label').each(
            function () {
                $(this).html($(this).html().replace('Username', 'Minecraft Username'));
            }
        );
        $('.message').each(
            function () {
                $(this).html($(this).html().replace('username', 'Minecraft username'));
            }
        );
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.