First, you do not want to edit core WP files, because your changes will disappear when there’s an update. That’s why you are encouraged to create child themes.
Second, you may want to peruse this Codex page on AJAX. Note that it shows how to handle both kinds of users (logged in and not logged in):
add_action( 'wp_ajax_my_action', 'my_action' );
add_action( 'wp_ajax_nopriv_my_action', 'my_action' );
The my_action
function would go in your theme files (when I was working on mine, I created my own plugin to handle AJAX).
Hope this starts you down the right path.
Related Posts:
- How to set post_id to 0 when you upload image via Add media button. (async-upload.php)
- Distinguish between 2 instances of admin-ajax.php
- Load minimum WordPress environment
- How to hide media uploads by other users in the Media menu?
- admin-ajax.php returns 0. How do I debug it and fix it?
- Add item to media library from blob or dataUrl
- AJAX action not triggering PHP function
- Using wp_handle_upload and media_handle_sideload with ajax
- Force redirect not logged in user to (wp-login.php or wp-admin) for specific page
- How to know what page is calling admin-ajax.php?
- Ajax image upload with media_handle_upload and form.js
- wp_handle_upload returns empty error array
- Pass additional parameter with async upload
- Ajax Request for both logged and non logged users
- WordPress is creating nonce as a logged in user but verifying it incorrectly
- How to disable drag-and-drop upload function in Media Library?
- Why is the file not uploading to the server?
- Filter images from media library by guid meta field
- Frontend AJAX Media Upload returning 404
- How do I set a maximum upload size for a specific user role (Editor)
- How to require files in a custom endpoint
- Cannot add multiple single images at once
- How to send custom variable in Media Uploader ajax request?
- wp_enqueue_media problem
- admin ajax is not working for non logged in users
- AJAX call not initializing for non-admins in WordPress
- Does WordPress Super User or Administrators can create and edit post and media on behalf of a user
- Removing custom physical folders with rmdir
- 400 Bad Request – Post to admin-ajax.php
- Could creation of various image sizes cause slow form submission response?
- unsharp thumbnails after uploading image
- Ajax is not defined
- JS global variable doesn’t update
- 400 Bad Request getting on AJAX Call
- ajax load more instead of pagination
- 404 error custom post type rest api
- admin-ajax.php 403 errors – no caching, permissions are fine
- AJAX and custom pages
- Ajax not sending the data correctly- Multidimensional array
- jQuery AJAX url wit variable
- React to AJAX adding to the page
- gform_after_submission does not work on ajax enabled form
- Updating Jquery object with newly created elements after AJAX call
- Is there a way to add ajax hooks without editing the functions.php file?
- Implement AJAX to fetch pages or posts content in a WordPress custom theme
- Images not displaying on site or media library
- How to update cart total after AJAX success
- Not getting ajax success response on insert/update row to database
- How to add Ajax to this Pagination i made?
- 400 Bad request while submitting form using AJAX
- Adding user using admin ajax by a user with custom role
- Hook after all metadata are set is triggering several time
- How can I run two AJAX requests simultaneously in WordPress?
- image not display in media library and thumbnail not display in post
- get a bad request 400 on my ajax-admin.php file
- Get posts by category via ajax
- check_ajax_reffer not working when logged
- Front-end uploader logging user out when they attempt to upload image
- Assign author on ajax wp post insert
- How to pass array from jQuery to PHP with AJAX in WordPress?
- Replicate Media Galley Edit view in Add Media View
- Download doccument on server rather than clients browser
- Ajax a php file that has Advanced Custom Fields in it
- wordpress admin ajax trash_comment
- Using existing ajax data that is loaded into page
- How to Protect Uploads, if User is not Logged In?
- Front-End Upload media with category
- Registration form AJAX check for existing username (simple version)
- Images uploaded via Gutenberg image block are cropped
- AJAX POST Value not being returned – WordPress – AutoTrader API
- Ajax call works for logged in users and returns “Bad Request” for guests [duplicate]
- Its possible to ajax update the content of the admin custom post type list
- WordPress custom ajax login not working on mobile browsers
- How to manually set an attachment in a post?
- Media Library: Remove replace images of selected author
- Wp admin ajax load more
- Failed to load resource: the server responded with a status of 404 (Not Found) admin-ajax.php
- What is wrong with my wp_insert_attachment code?
- Handle image file and save it to media
- wordpress ajax search posts
- Issue developing an AJAX form with WordPress
- How to check Ajax request only when i opened the Notifications list?
- Adding attachment custom field metadata to TinyMCE tag
- Javascript output now showing in custom widget
- Editor User Role can’t see other users media
- All WordPress AJAX calls always return 0
- Load oEmbed iframe within ajax call
- AJAX is not submitting data to database
- Ajax call from Plugin using Class
- Adding pagination to Ajax Query
- Ajax call not working anymore
- Bulk upload images in upload folder does not show in media library
- Ajax global variable is not getting saved (returns null)
- Trigger action via button
- Ajax call on class returns old data
- WP admin ajax Pagination issue
- enqueue style using admin-ajax.php
- How to safely pass post_id and user_id via AJAX to the backend (prevent user from changing it via JS)?
- Syntax error on query_vars while handling with Jquery
- how to enable ajax on submitting of contact form 7?