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 6061349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:55:40+00:00 2026-05-23T08:55:40+00:00

I’ve been developing a pretty simple WordPress plugin, and wanted to do some live

  • 0

I’ve been developing a pretty simple WordPress plugin, and wanted to do some live validation of certain fields on the page, which is where I am stuck. I’ve been looking everywhere for something that worked, and I simply can’t make it function.

I’ve been trying to get the ajax to function properly and I know I’m missing something obvious, I just can’t figure it out.

The main function file includes this to register my js file.

function on_screen_validation() {
    wp_enqueue_script( "field_validation", path_join(WP_PLUGIN_URL, basename( dirname( __FILE__ ) )."/field-validation.js"), array( 'jquery' ) );
}
add_action( 'admin_print_scripts', 'on_screen_validation' );

The js runs this code to capture the onblur command and pass the value to the php validation file.

jQuery(document).ready(function() {
    //run field validation on username on blur
    jQuery('.valusername').blur(function() {

        var usernameID = jQuery(this).attr('id');
        var usernameVal = jQuery('#'+usernameID).val();
        var thisFunction = 'validateUserName';

        jQuery.post("mywebaddress...validation.php",{Function: thisFunction, thevars: usernameVal}, function(data) {
             alert(data); //would update validation message here
        });
    });
});

And the validation.php script looks like this:

if(isset($_POST['Function'])){
    call_user_func($_POST['Function'], $_POST['thevars']);
}

function validateUserName($username){   
   if ( username_exists($username) ) {
       echo $username.' does exist'; 
   } else {
       echo $username.' doesnt exist';
   }
}

Obviously I’m just using alerts for now to make sure the data is being checked properly.

If I take out the WordPress username_exists function, and just echo back a string, it works fine. But with username_exists, it creates a 500 internal server error. I need to know how to get this external validation.php file to recongnise WordPress functions (I think), and nothing I’ve found so far will work.

Thanks for reading… sorry for the long explanation I just wanted to make sure the context was all there so it made sense (I hope!)!

Cheers, Matt

  • 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-05-23T08:55:40+00:00Added an answer on May 23, 2026 at 8:55 am

    I asked the same question over at WordPress Answers – https://wordpress.stackexchange.com/questions/20915/wordpress-plugin-admin-page-using-wordpress-function-in-linked-php-file

    I thought it best to simply link to the answer that helped me =) Thanks all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.