Instead of doing this, simply write your own function inside the verifyapi.php
and then include it in your plugin’s main file, by using this:
require_once('verifyapi.php');
This way, you have access to WordPress’s function inside your verifyapi.php
file.
Now, inside your verifyapi.php
file, create an Ajax handler (however I would recommend using a REST endpoint) :
add_action('wp_ajax_your_', 'handler_function');
add_action('wp_ajax_nopriv_your_handler_name', 'handler_function');
function photogram_ajax_handler() {
// Your verification here
}
So far so good. One last step is to change the URL to admin-ajax.php
. To do so, use this:
...
url:"<?php echo site_url('/wp-admin/admin-ajax.php'); ?>",
...
All set.
Related Posts:
- ajaxurl not defined on front end
- Why does WordPress add 0 (zero) to an Ajax response?
- Saving data-URI to media library
- Nonces can be reused multiple times? Bug / Security issue?
- How can I run AJAX on a button click event?
- What is nonce and how to use it with Ajax in WordPress? [duplicate]
- Empty POST data on server on AJAX request using Angular $http
- Build path for a custom portfolio plugin
- Using AJAX in a plugin to submit form – REALLY confused
- wp_localize_script $handle
- How to enable users to down-vote in this simple voting counter (that uses the post meta)?
- get all products of one category
- Plugin Settings not Saving on Ajax re-ordered table
- How to post form in ajax mode and handle it in wordpress
- Using Ajax call in jQuery doesn’t work in widget
- WP_LOCALIZE_SCRIPT doesn’t work
- Timeout on Admin-Ajax?
- Comment `Reply` link doesn’t work if comments are loaded from ajax
- Ajax in WordPress – path issue
- Cannot search post by taxonomy
- WP AJAX is not working, always returns 0
- Ensure function has completed before allowing another Ajax call
- Frontend Ajax call not working using wp_ajax, wp_enqueue_script and wp_localize_script
- include wp-blog-header not working on MAMP
- Slow WP_query due to nested wp_query. Need Suggestions
- .mo translation strings not loading in PHP scripts that handle AJAX calls
- How can I pass get_the_author_meta(‘user_email’) through the REST API?
- Woocommerce checkout update totals with datepicker
- Including the necessary functions for a custom ajax registration form
- How can I rewrite a URL to pass requests to a custom method via AJAX? (I can’t use admin-ajax.php)
- get post attachment using ajax
- Dashboard – get status and position of metaboxes and pass them to ajax method
- how to search users by ajax live search
- Storing data in wordpress database from ajax call from different website
- Create custom HTML/JS app inside page
- jquery & ajax sending data to php
- wp_localize_script is not adding a global variable for javascript
- Can’t get AJAX call working in custom plugin
- Remove entire [$key] from array stored in custom field using Ajax – unset($array[$key]); not working
- 400 Bad Request, in wordpress theme development, wp_ajax
- Ajax is not working in a loop
- Are there any security risks when submitting data-attribute data through AJAX?
- How to get error object returned by wp_create_user
- Ajax: Populate with content from a post’s ID not working – duplicating current page html instead
- Data not insert and update through ajax and jQuery in admin page?
- Setting a JSON web token from a secondary api as a secure cookie on WordPress
- How do I get rid of my inclusion race-condition on wp_enqueue_script
- Issues Updating Post Meta with AJAX (Seems simple but cannot figure it out)
- ajax working when function is on child theme but not in plugin page
- AJAX call to admin-ajax.php by subscriber returns home page
- Ajax function is not working on WordPress
- About a programming language starts with [closed]
- add_action wp_ajax_ not loading in plugin file WP Network
- Workflow for new importer plugin – your advices?
- Ajax +wordpress onClick link redirect to new page and create html content
- AJAX request not routing through proxy
- WordPress (pagenow link) in ajaxurl change after i change plugin language
- Ajax on the Administration Side of plugin – returns 0
- How to do admin ajax request in a plugin for rest api
- Ajax action has 200 status but response of No response data available for this request
- Jquery php request is returning a weird result
- WordPress Does not grab the string sends useing AJAX response, wp_ajax hook
- Posts form with AJAX request – Plugin development
- GET request return value as error instead of success
- Bad request 400 using class based files
- Trying to run a Ajax request from a checkout form in woocommerce via a custom plugin
- ajax stopped working when not logged in wordpress
- ajax response strips multidimensional array and unable to decode
- 400 Bad Request and illegal invocation in wp_ajax based on processData set to false or true
- Rate limiting ajax requests in WordPress
- ajax-action.php can’t find added action
- Using AJAX to submit and return data inside the WordPress Plugin Boiler Plate framework
- AJAX call of function containing javascript which is not loaded (Plugin development)
- Performing ajax request in wordpress
- $_SESSION inside php function executed by AJAX
- Two same AJAX calls – one is working, other doesn’t
- ajax multiple Values
- How to include files in the loop via ajax
- How to handle ajax Request in a complex-structured plugin?
- wp_ajax add_action fuction won’t fire on custom jQuery action
- Filterable posts using categories
- How to get values from Tinymce visual editor popup?
- Ajax Response Error | just getting error as the response
- PHP includes with AJAX actions
- admin-ajax.php returns “No Script Kiddies!” sometimes
- WordPress function is not called and ajax return 0
- Ajax call not working with
- Ajax functionality not being called under wordpress plugin
- WP Ajax on page load not working on bluehost but was working on Godaddy
- WordPress plugin: admin-ajax.php not passing data to custom function
- Can’t get query string in ajax call
- Ajax functions – no access to wp-admin.php only online
- An adiitional function fires on my AJAX submit
- Fatal error: Call to a member function query() on a non-object in my ajaxpage
- Page reload occurs before request finishes
- PHPUnit Ajax Serialization of ‘Closure’ is not allowed
- Trigger a JavaScript function based on the data fetched from Woo commerce hook
- Return custom product in ajax call loop
- Why my admin-ajax url returns 0 even after adding echo and die() at the end of function?
- WordPress plugin boilerplate AJAX functionality