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
- Enforcing password complexity
- How to create shortcodes that pull custom field data from general settings
- the_title() & the_content() are retrieving Post details inside a Page, after calling a shortcode
- Audio tags around Mp3 URL in content
- Wrap each shortcode in array to div
- Template part inside shortcode, unexpected reult
- Shortcode Inside Class Not Working
- How to call function at the bottom of post using plugin?
- How to add custom post meta to default blog post?
- Shortcode API: How to get name that matched shortcode RegEx?
- Shortcode content filter?
- WP add_action factory
- Swapping wp_dropdown_categories function with wp_category_checklist
- How to show phpinfo() only in a new tab?
- How can I remove a function that has been added to wordpress with add_filter?
- Get value from shortcode to do something
- How to use $_GET function WordPress backend
- Custom shortcode outputs plain text instead of HTML at top of post
- Saving plugin settings – ERROR: options page not found
- Shortcode returns values in the wrong order
- class_exists returns different values [closed]
- Custom array from a query only write the last row of the query
- ::before on open/close function [closed]
- Create a WordPress shortcode using PHP [duplicate]
- Unable to process php via shortcode
- Can’t upload CSV file to plugin directory using custom upload form in admin panel
- Validate and Sanitize WP REST API Request using WP JSON Schema?
- Cant display an image via PHP in wordpress
- Shortcode for a Series of Elevating Image Files, Excluding a Range?
- Shortcode won’t execute
- Set document title through shortcode plugin
- Ajax on the Administration Side of plugin – wp_localize_script – how to pass value from JQuery to PHP function in class?
- WordPress can’t use ZipArchive
- How to change basename url for wp-admin?
- How do I reopen the (Popup Maker) after entering the correct password for a password protected page?
- WordPress loading progess – wp-blog-header.php
- Illegal string offset checkbox
- Use PHP Class in WordPress functions
- Custom plugin: how do I call a PHP file if settings option is set to true?
- wp_update_post gives 500 internal error
- register_setting not save checkbox
- How to add a PHP scripts into WordPress
- How to give custom roles the capability to edit one Menu instead of every Menu
- Multiple Arrays for Custom Post Query using Boostrap accordions and ACF repeater fields
- Replacing entire tag with shortcode – JavaScript [duplicate]
- Shortcode just with a php code
- add menu page in loop menu order
- Private messaging – Getting and displaying the avatar/url of a message recipient
- Custom fields changes the formatting of metabox input
- widget: input the px value from user and use it as inline style in widget function
- Contact form field in wordpress menu
- php string inside shortcode does not work
- Limit the number of successful logins
- Shortcodes (with a space) added to php Sample
- How can I put a custom field as the link of a button shortcode?
- WordPress rewrite question
- Problem using explode inside add_shortcode() callback funciton [closed]
- SHARING TO FACEBOOK – FROM DYNAMICALLY GENERATED PAGE
- Cannot modify header information – headers already sent
- Display Current Time using shortcode
- How to create shortcode of this PHP code
- Query posts by custom taxonomy slug in WP REST API?
- oneOf JSON Schema validation not properly working for custom post meta value?
- Too few arguments at registering new templates in my plugin
- I want to lists posts in wordpress to nearest location entered by the user
- How to sort custom sortable column by custom table value
- How to edit a widget code?