The error is quite self-explanatory. Your last lines are:
add_action( 'wp_ajax_my_action', 'my_action_callback' );
add_filter( 'wpforms_smart_tag_process', 'my_action_callback', 10, 2 );
The action is calling the same function as the filter. But the filter passes two variables and the action only one. The function itself expects two variables:
function my_action_callback($content, $tag)
So if you call the function through the (ajax) action, you get this error. You’ll have to pass $tag
through your ajax call as well. Otherwise my_action_callback
wouldn’t do anything anyway, because it demands $tag
to be 'total'
. Or you could ditch $tag
as a variable, since it is not doing a lot anyway.
Update: you can also make PHP
be more forgiving by adding defaults in the function call:
my_action_callback($content="", $tag='')
Related Posts:
- Get URLs for AJAX Filter Checkboxes WordPress
- Remove Actions/Filters added via Anonymous Functions
- How to restrict actions and filters “properly” by conditions
- Using add_filter() in Widgets
- AJAX handler throws 400 (Bad request) – why?
- ajax live search for post title
- Convert hyphen to underscore in permalinks
- Display a function using AJAX
- Unable to get_the_content(); of a post in WordPress via AJAX
- Ajaxing function in widget class
- How to update feed only 2-3 times a week (for Feedburner email)?
- woocommerce target button with class after ajax update
- How would go about if I just want a temporary function?
- Accepted arguments value in hook functions
- Which action hook to use for function?
- Modify a function without editing template
- How do I add Bootstrap and LESS to my migrated WordPress site?
- WP Ajax Function Always Returning undefined
- Scripts not appending to element in AJAX call – why?
- How to search using ajax for exact phrase or words in an input field?
- jQuery does not work
- Override the WordPress core function wp_referer_field
- echo custom fields with AJAX
- login_headertitle is deprecated since version 5.2.0
- Insert Content Before div#main from the functions.php File
- Are innerHTML elements visible to jQuery functions?
- get content from page through AJAX
- Populate Product Regular Price with a calculated ACF Field Value
- Ajax Form Issues using Lightsail (AWS)
- Save_post – Warning: Cannot modify header information
- What is the earliest Hook a Script can use?
- How Do I Unhook This Parent Theme Function?
- How to use `foreach()` in ajax call
- Multiple Notifications SetInterval
- wp_ajax add_action fuction won’t fire on custom jQuery action
- WordPress Ajaxifying not working properly
- Which method is more correct for removing WooCommerce Extensions menu item?
- Load scripts into an AJAX div
- Load scripts into an AJAX div
- True parameter but jquery register in header and not in the footer with wp_register_script
- Automatic add space if user enters number(any digit)
- previous_post_link inside of a function?
- functions.php filters not applied in AJAX call
- Settings in functions.php used by a plugin
- Ajax call does not work for this custom code
- AJAX: WordPress filters inside $html do not work as intended
- AJAX values converted to PHP Variables?
- iOS and ajaxComplete
- How to get variable from other function inside class function using add_action for Ajax call
- disable a specefic sidebar when user is log out
- Remove Actions/Filters added via Anonymous Functions
- Prevent function from triggering on current page
- Using AJAX on frontend: Synchronous XMLHttpRequest deprecation except for admin role
- use add_action in a shortcode (gravity form – WordPress)
- Assign IDs to headings in ACF using functions.php
- wp_footer hook causing text to show on bottom of page
- Remove action hook from Class, understanding OOP
- How to change form action of wp-login page with a function
- How To Display Author Popup on Entry Meta (Genesis Framework)?
- function replace_text for entire page
- How to call a function from functions.php with ajax?
- i can’t use wordpress functions in ajax loaded php file
- Function stops working
- add product thumbnail to checkout page only and include variation name
- Redirect specific author posts to another url
- admin-ajax.php 403 forbidden only when calling from external file
- How do i create a search option for pdf’s only
- Remove External Links from WordPress posts Using add_filter() in Theme functions.php
- ACF Filter return value
- Execute jQuery with custom event listener after successfully add an item to the cart
- Graphic before title – Specific Category
- $content is empty while using DOMDocument
- Hide disclaimer from summary excerpts
- WordPress hooks to call a function inside a construct
- Change add_filter based on Ajax
- Find the method which AJAX GET calls
- How to create admin ajax function for my contact form
- admin-ajax.php & my wp-admin folder url showing in header
- wordpress function through ajax not being called
- Only seems to be displaying one child when there are supposed to be multiple
- Best way to add image to recent posts widget?
- same get_posts function works diffrently in tag.php and functions.php
- How to make an If Else on Excerpt Filter
- wordpress ajax is not working for dropdown selection
- Why might wptexturize have become re-enabled?
- Fatal error: Call to undefined function add_action() – an untouched problem
- Sending Messages Back to the Template After Processing?
- Shortcode to eliminate and replace with
- WordPress Jquery+scripts enqueue issue
- Pass arguments to function class with do_action()
- Search and Replace Script Loader in Head Only Works in Footer
- Regex works in regexr, but not if I filter content [closed]
- Moving CDN jQuery to footer does not work?
- custom COOKIE on custom page
- Retrieve a custom form field modified by a filter
- Adding a jQuery rotator function
- What add_action reference should I be using or should I use do_action?
- AJAX login without a plugin does not work. when add a action to function.php
- Pass max posts to Javascript
- Updating site content after an AJAX call without a page reload