You need to allow AJAX requests for guests too. Usually when a WordPress AJAX call returns 0, it means that there are no capabilities for the user to perform that action.
Also, your debug info showed Guest
.
Alter your function to include the nopriv
AJAX for guests:
add_action('wp_ajax_nopriv_fahadsending_mail', 'fahadsending_mail');
add_action('wp_ajax_fahadsending_mail', 'fahadsending_mail');
function fahadsending_mail(){
$to = "[email protected]";
$subject = "Donation";
$message = "message message message message message message message ";
if( wp_mail($to, $subject, $message) ){
echo "mail sent";
} else {
echo "mail not sent";
}
die(); // never forget to die() your AJAX reuqests
}
Related Posts:
- wp_mail 200 response but no mail sent
- need a confirmation text to appear on email submission
- Adding user using admin ajax by a user with custom role
- Sending email with wp_email and AJAX
- Run PHPMailer function after ajax function completes that adds row to custom table
- JavaScript implementation of Gzip
- How to cache json with wp-super cache
- Why might a plugin’s ‘do_shortcode’ not work in an AJAX request?
- Get Previous & Next posts by Post ID
- Nonces and Cache
- ajax – why multiple calls to wp_create_nonce() return same value?
- AJAX request on the frontend always returns 0 if user is not admin
- Admin Notification after save_post, when ajax saving in gutenberg
- Using ajax on categories and wordpress loops
- Cannot load admin-ajax.php. No access-control allow origin*
- Initialize JS with an ajax loaded ACF form
- WordPress Nonce Issue for Ajax Login and Logout
- How to modify wp_ajax function?
- Nonces and Ajax request to REST API and verification
- Vue.js + AJAX Shortcode
- Turn jQuery.ajax() request into XMLHttpRequest (vanilla JavaScript)
- wp_ajax action is not running
- WordPress AJAX calls not detecting language properly?
- AJAX issue – Uncaught SyntaxError when processing Zip File
- wp_verify_nonce doesn’t return true on server when it matches the nonce
- update_user_meta doesn’t work with AJAX
- How do I set the url to make an ajax request for a html document?
- wp-admin AJAX with Fetch API is done without user
- Ajax stops working when logged in?
- Using wp_handle_upload and media_handle_sideload with ajax
- Populating content dynamically via AJAX and Advanced Custom Fields [closed]
- Create Page With wp_insert_post() and AJAX
- Load ajax if is_home()
- How to know what page is calling admin-ajax.php?
- Populate a Map at The Same Time as showing Posts via AJAX
- wp_localize_script not working on ajax response
- Get wp_title wp ajax
- Why Does WordPress not output admin-ajax.php path by default?
- PHP 8, AJAX mail form to function.php doesn’t work
- SSO autologin WordPress + Ajax
- Speed/Performance difference between `wp_ajax` and `init` checks for AJAX/POST requests?
- Test WordPress api with postman
- How to handle 400 status in Ajax [duplicate]
- Remove trailing 0 from function that is used both statically and dynamically
- How to process wordpress ajax call without action parameter?
- WordPress ajax works on FF but not on IE & chrome
- Disallow second login session
- All AJAX requests return a 400 error
- Unable to successfully verify nonce
- Create custom POST Method URL
- POST Ajax bad request
- Getting a variable using $post ajax back from php to js response in WP
- AJAX Call – Failed to load resource: the server responded with a status of 500 (Internal Server Error)
- WordPress is Not Setting PHP $_POST on Custom Ajax
- bulk update meta value with ajax
- Ajax for subscibers not working
- Is it possible to determine whether a page is a page template by page_id in ajax call?
- Chained ajax call, second call returns 0
- PHP session when called wp_ajax_nopriv
- What exactly does ‘authenticated’ mean for wp_ajax_nopriv?
- Use AJAX in a WordPress Plugin to Get Data From Custom Database?
- How to make image in TinyMCE clickable
- How to use Jeditable plugin with admin-ajax.php?
- Ajax mousedown call getting “cancelled” when clicking link
- WordPress Ajax Not Firing
- Get uploaded attachment width & height and attachment ID after upload them
- Uncaught TypeError: Cannot read properties of undefined (reading ‘message’) [closed]
- Disabling ajax code that does a POST request that ends in a 400 error code
- Refresh checkout fields on add to cart with order bump
- Add Server Side validation in Ajax mail form
- Is it good practice to use REST API in wp-admin plugin page? [closed]
- How to prevent my external API call from being called by anyone but me (my site)
- Ajax not sending the data correctly- Multidimensional array
- get a bad request 400 on my ajax-admin.php file
- Registration form AJAX check for existing username (simple version)
- How to check Ajax request only when i opened the Notifications list?
- All WordPress AJAX calls always return 0
- Trigger action via button
- Syntax error on query_vars while handling with Jquery
- Want to send ajax request in wordpress to a custom file in plugin
- How to send the checkbox value to email
- how to get password from user instead wp-generate-password
- Class called in template, AJAX not registering
- Same query in category.php and in function.php, but different result
- How to use nonces for frontend AJAX voting if the page gets cached?
- AJAX Call in Plugin Returns More than JSON
- Ajax take too long to return code
- problem when adding wp_editor with ajax [duplicate]
- Get wp-load.php PATH with wp_localize_script and JavaScript for plugin
- Ajax Form seems to post, but does not return
- Ajax request to admin-ajax.php and window.location.href
- Objects and get_post_meta() gives me 1 string for latitude and longitude
- Why can wordpress not find the actions I add in my constructor?
- delete attachment for one post without deleting actual attachment post
- Memberpress isn’t cooperating with WooCommerce
- where does my function output from load-* go?
- WordPress ajax requst returns zero
- wp_editor() in content that was loaded with ajax [duplicate]
- WordPress blocking polling request when signed into Admin
- Send button using own contact form [closed]