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]
- Fatal error: Call to undefined function plugin_dir_path()
- Looking for a better way to handle an ajax script that pulls in post data on click
- How to add default images into theme customizer image control?
- wordpress custom endpoint multiple params
- Can’t use get_results() in ajax query
- Admin-ajax.php appending a status code to ajax response
- Access/update database with jQuery
- Passing jQuery value using Ajax to a page template
- Why is this Ajax not working?
- Ajax return code 400
- Insert array data on plugin activation
- Adding Default Settings to Theme My Login plugin
- How to make drop down post title
- ajax, right way to do it and make it works?
- Hide categories that are not used in the post type
- Problem with custom plugin using AJAX to pull info from php file
- filter default query to show just selected level of child pages in wordpress
- Call a PHP Function with Multiple Parameters that is outside the AJAX Handler
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- How to make my custom widget appear within WordPress widgets? Plugin development
- WordPress, AJAX and pre_get_posts using conditional tags
- Refresh table data with Ajax
- Font Awesome changing default WordPress Font
- Download full html page with CSV export plugin
- unable to use ‘new WP_Query’ in AJAX call
- admin-ajax Firing Error 400 When Logged In
- WordPress Ajax Always returning 0
- Usage of call back function of add_meta_box()
- Woocommerce with Lazy Load php and ajax
- how to save checkbox data for custom setting?
- How to Schedule Cronjobs for start of every month and year
- My jQuery Ajax form submit is still refreshing page?
- Submitting a form, using Ajax, to run a SQL Select query based on user input from the form
- WordPress WP_Query without query GET parameters
- Where to copy woocommerce files to in my custom theme to avoid editing the core plugin?
- How can I get plugin meta data without knowing the plugin folder?
- Ajax URLs without #!, how to prevent falling into single.php on load or reload?
- Load more posts using AJAX based on posts inside WP_Query
- PHP calling AJAX function that relies on passed PHP function values not working
- Plugin won’t output characters with diacritics properly
- How to use wp_ajax_set_post_thumbnail?
- WP Hook Before a post is created
- ACF relationship on user profile page used for allowed access
- Can an AJAX callback function access a PHP variable which was defined during initial page load?
- Store user form submitted information in post type
- How to reload a php script, using AJAX and jQuery
- Need help with format of nested array in MySQL
- Top Authors list by highest post views with Ajax pagination
- Offset with ajax load more posts duplicates
- How to add delete, approve, spam Links to Comments
- Setting at job with shortcode not working
- Run code before WordPress loads and insert data into WP if need be
- PHP: Why does my code work in index.php but not a widget?
- Ajax Load more CPT via shortcode
- MySQL query in WordPress with AJAX
- Is custom behaviour possible when asynchronously uploading?
- Fatal error: Uncaught Error: Call to undefined function wp_nav_menu()
- Data inserted in database, but ajax calls error function
- I’m not able to get access $wpdb in my php file in wordpress
- How do I change the Go To Categories link in the term_updated_messages
- how to display tables via ajax
- Login user into magento using wordpress account
- Customize create table SQL statement in any WordPress plugin