It’s not entirely clear what your ultimate goal is, but a simple way to catch a form submission is to hook init
and check if something is set:
function wpd_check_post_vars(){
if( isset( $_POST['first_name'] ) ){
// do something
}
}
add_action( 'init', 'wpd_check_post_vars' );
There’s no connection here between the action and your Shortcode, it’s not really necessary. An important point to remember is that actions don’t persist beyond the request they’re added on. If you add_action
after its corresponding do_action
is triggered, nothing will happen.
You should also probably use something more unique than first_name
.
Related Posts:
- Retrieve multiple values passed to a single attribute in a shortcode
- Display a text message if the shortcode is not found?
- add_meta_boxes action with refresh on save
- Use wc_enqueue_js only on specific pages – nested add_action
- Loading page template into shortcode
- My shortcode is showing up twice
- Custom plugin issue when trying to use the shortcode twice on a page [closed]
- Making Quote Plugin more efficient
- How to access function from outside of a class within this class in WP plugin?
- action hook wp_head higher priority as all other plugins/hooks
- custom shortcode will not display the wrapped content
- Adding Default Settings to Theme My Login plugin
- Append HTML Using Shortcode
- Plugin CSS not enqueing
- Adding widgets to my plugin page instead of WordPress dashboard
- Adding function to Genesis genesis_header [closed]
- Is it possible to define variables in a wordpress shortcode, and then call the shortcode using a specific variable?
- WordPress shortcode returns the data before
- Woocommerce custom Plugin in wordpress [closed]
- What is the difference between Null vs Empty (Zero Length) string?
- How to Create custom block for displaying information in content section which act like shortcode
- Display a custom name when the user has no name settle in his account
- I want to hide “sold by” on certain pages with id page 43
- overwrite wordpress gallery with custom gallery shortcode
- How to return html as a string from php for WordPress
- How do I remove an action hook inside a class that is called by another class?
- Add two or multiple functions in WordPress Post or Page
- Shortcode Works for Logged in Users but Not Working for Guest
- Submit to itself don’t work
- How to execute add_action() function from custom plugin to Crontrol plugin or do_action()?
- using a shortcode in a hyperlink
- WP Custom tables query
- Custom plugin with shortcode not working
- Too few arguments – wp_login action
- How to add custom post meta to default blog post?
- PHP code inside shortcodes
- Use WP_Query in shortcode
- Shortcode API: How to get name that matched shortcode RegEx?
- Instantiate class to be available to all plugin functions
- Common abstract class for plugins
- Shortcode content filter?
- How to test nonce with AJAX – Plugin development
- What does $wpdb->get_row return?
- Create shortcodes within foreach loop (using array)
- WP add_action factory
- wp_loaded hook block script enquequing
- WP nonce invalid
- Custom Theme, Custom shortcode not working
- woocommerce subscriptions – get expiration date [closed]
- Same log message keeps on printing to debug.log file thousand of times
- Trigger popup in a php if/else statement
- action is not called after a php request
- 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?
- Delete a WordPress transient from a shortcode on Page/Post update
- Remove an action hook within a Class
- Ajax not working es expected (Returns 0)
- Why is file_get_contents returning page source?
- Create onClick Event to Re-load a Widget
- Swapping wp_dropdown_categories function with wp_category_checklist
- Accessing the database from a plugin outside of action hooks
- How to pass arguments to add_action() or retrieve return value of called function?
- Adding subdomain to home_url for “add_menu_page”
- How to show phpinfo() only in a new tab?
- 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?
- Custom Form Processing Issue
- Different loop output every x posts in custom post type
- add_action shortcut?
- How to output a PHP file values by shortcode?
- Showing content from one page on another
- Is it acceptable to treat a filter like an action?
- How to access global variable $menu inside a class function
- Ajax – Call to undefined function get_option()
- wordpress plugin is not activating from widget
- Showing a different gallery in a seperate post
- How to display posts by current user in a drop down
- Create own WordPress shortcode gallery
- Hide categories that are not used in the post type
- add element with add_action to posts from a specific category ID
- 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
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- How to sanitize any integer input field in wordpress?
- Get value from shortcode to do something
- How to set up VS Code for WP plugin/theme development in 2021? [closed]
- WordPress ajax doesn’t display object method on jQuery .change() function
- How to exclude category ID from Looper in WordPress
- Custom user login page by creating a plugin
- Add a specific part of current category page url to shortcode
- How to display data from custom table in wordpress phpmyadmin
- Calculating a large number of MYSQL queries as customshort codes, slow
- Singelton class does not work, multiple initialization on page reload
- Saving an array of dynamic repeater data as post_meta
- what is the best practice to add new field to an api route
- filter default query to show just selected level of child pages in wordpress
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- WordPress wpform plugin submit and get multiple checked value from checkbox [closed]