You are serializing your form data before posting it to your PHP function, but you do not unserialize it at the other end. Therefore your check for $_POST['attend'] == 'yes'
will always fail.
Try the following (untested).
function eventAttend() {
$fields = array( );
parse_str( $_POST['data'], $fields );
if($fields['attend'] == 'yes') {
global $wpdb;
$wpdb->insert('wp_event_attendants', array( 'event_id' => $fields['event_id'], 'user_id' => $fields['user_id']));
echo $wpdb->print_error();
}
die();
}
Related Posts:
- Do I require the use of nonce?
- simple wordpress ajax plugin not working when not logged in
- Problem with WordPress Ajax form
- How to set a custom path, for ajax image upload folder in admin?
- admin-ajax.php responding with 0
- Page Reloads Before AJAX Request Finishes
- wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
- How to test nonce with AJAX – Plugin development
- Create onClick Event to Re-load a Widget
- WordPress ajax doesn’t display object method on jQuery .change() function
- adjust section according to country?
- How to send Ajax request from my plugin in admin dashboard?
- AJAX success response is not working but it’s saving my changes
- how to update and display an option without reloading the page
- Using data sent via AJAX in multiple functions on a WP plugin
- Problem with AJAX in wordpress plugin
- Any ideas why I am getting “I’m getting “wp-admin/admin-ajax.php 401 (Unauthorized)”
- Execute Jquery when a specific page in my plugin is loading
- PHP: How to access db the right way in plugin?
- calling admin-ajax.php from admin-ajax.php
- How to use wp_send_json() and output the value with ajax?
- Ajax on the Administration Side of plugin – wp_localize_script – how to pass value from JQuery to PHP function in class?
- Is it possible to access admin-ajax.php using PHP?
- Settings API form – submit with AJAX
- Post form – AJAX won’t upload featured image – Plugin development
- How can I get my WordPress plugin to receive data and relay it in an ajax/php request to a remote server that requires authentication?
- Submit remote form to wordpress REST API and save data to custom post type
- custom mailchimp form using HTTP API
- 400 bad request admin-ajax file upload
- Input field duplicates on form submit by jQuery
- Ajax in a class instantiated via shortcode
- defined (‘ABSPATH’) false after AJAX post to other PHP-file
- AJAX & PHP | Call a specific PHP function from a PHP file via AJAX?
- Cookie not created in AJAX request
- How to pass and validate nonce in custom REST routes
- getJSON response to PHP
- ajax problems on loading page [closed]
- Woocommerce add to cart quantity buttons with AJAX
- WP add_action factory
- wp_loaded hook block script enquequing
- Why is the post meta[] empty when I make a call to the wordpress rest api?
- WP nonce invalid
- class click counter save number
- woocommerce subscriptions – get expiration date [closed]
- Same log message keeps on printing to debug.log file thousand of times
- Any possible way to make $wpdb->get_results() return anything else than array?
- get post based on category chosen in drop down – The ajax method
- Why is $_REQUEST an empty array in admin-ajax.php?
- Adding Default Settings to Theme My Login plugin
- Checking for new message using AJAX and PHP. Server overload?
- Custom filter in admin edit custom post type responding with invalid post type?
- WordPress Scheduled Event Request Blocking
- How can i upload images in an admin page?
- Append HTML Using Shortcode
- AJAX request status 200 but no actual “response”
- get current custom post ID by WP_Query method
- Delete a WordPress transient from a shortcode on Page/Post update
- How to make drop down post title
- Ajax not working es expected (Returns 0)
- Plugin CSS not enqueing
- Swapping wp_dropdown_categories function with wp_category_checklist
- Accessing the database from a plugin outside of action hooks
- Adding subdomain to home_url for “add_menu_page”
- How to show phpinfo() only in a new tab?
- Load a page into a div with Ajax
- How to find error in my code when the error message is pointing to WP core file?
- How to select the contents in the text view textrea in wp_editor?
- Creating a Multi-Level Associative Object Using AJAX
- wordpress count link clicks by ip address
- How to access global variable $menu inside a class function
- Ajax – Call to undefined function get_option()
- ajax, right way to do it and make it works?
- Hide categories that are not used in the post type
- Automated Cart Update With Alert Box Each Time
- How can I remove a function that has been added to wordpress with add_filter?
- PHP Fatal error: Uncaught mysqli_sql_exception: Table doesn’t exist in wordpress/wp-includes/wp-db.php
- Ajax load more posts with multiple tax query
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- Ajax call not working
- How to store data from multiple forms using ajax and php
- Using a custom plugin to capture input data via Ajax and PHP
- How to sanitize any integer input field in wordpress?
- WordPress Sending data to Ajax with select option
- PHP 8, AJAX mail form to function.php doesn’t work
- How to set up VS Code for WP plugin/theme development in 2021? [closed]
- Ajax loaded form replaces form action with Ajax url
- Ajax category filtering products default show all
- Custom user login page by creating a plugin
- prevent default not stopping page refresh. Passing form information to and from php with ajax in a wordpress site
- Status 400 for AJAX POST Request with admin-ajax.php
- Singelton class does not work, multiple initialization on page reload
- Problem with custom plugin using AJAX to pull info from php file
- Saving an array of dynamic repeater data as post_meta
- what is the best practice to add new field to an api route
- Gutenberg block – Save PHP function’s output as HTML?
- filter default query to show just selected level of child pages in wordpress
- Ajax random number always the same
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- WordPress wpform plugin submit and get multiple checked value from checkbox [closed]
- Call a PHP Function with Multiple Parameters that is outside the AJAX Handler