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
- ajax category filter
- Call to undefined add_action() in theme’s functions.php
- How can I rename the WordPress AJAX URL? [duplicate]
- Exclude Empty Child Categories in Menu
- Add external js file to footer with id
- add_filter priority problem
- Clean-up script tags
- Super simple shortcode not working
- How to filter out shortcode when displaying the_excerpt() in the loop?
- How do I pass arguments for multiple functions hooked to a single action?
- Last updated date function
- add_action shortcut?
- is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript
- Are there actions or filters I can use for Ajax calls?
- How to set default archive image without overriding first attached image? [closed]
- How to make custom column Admin>Users sortable?
- Get Current Post ID in functions php, meta query filter
- Output and filter data from a XML url
- Ajax post filters not working
- What did I do wrong in my functions code, that will not change the “Get New Password” text to “Send It”?
- How to know which ajax file or function is called for action
- How to filter $content in shortcode function
- Jquery implementation not working on page reload
- Reuse variable in hook callback
- Multisite Ajax serialize return error [object Object]
- PHP mixed with some JS code to update WordPress theme settings
- WordPress listen to $_POST in functions.php
- wordpress use single ajax in place of multiple ajax requests in a smarter way
- Add Element as a Filter to the_content
- Can’t properly set the_title add_filter to show short_URL
- Auto-Tweet if Type is ‘Status’ using OAuth
- Filter nav menu items HTML tags and wrap inner text with span
- wp_enqueue_script | Help me figure out what is causing jQuery is not defined
- How to add custom li item to wordpress menu
- How to display an image before title text in menu items
- Postback redirect through add_action is not triggered
- How to add class dynamically from templates
- WordPress Ajax filter: Create two loops for different output styles?
- How to change form action of wp-login page with a function
- How to call a function from functions.php with ajax?
- Execute jQuery with custom event listener after successfully add an item to the cart
- WordPress hooks to call a function inside a construct
- How to create admin ajax function for my contact form
- How to make an If Else on Excerpt Filter
- Pass arguments to function class with do_action()
- Retrieve a custom form field modified by a filter
- What add_action reference should I be using or should I use do_action?
- Force resize for all video content
- Way of getting queried loop before the query with a filter hook?
- ajax form function error
- Trying to get this function to show below the content