Like kaiser answered template_redirect
hook is indeed appropriate for redirects.
Also you should use wp_redirect()
function, rather than setting header.
Related Posts:
- Difference Between Filter and Action Hooks?
- Init action hook running late after PayPal’s return url?
- How do you use the plugin boilerplate loader class to hook actions and filters?
- How Do I Load My Action Earlier Enough?
- Does WP fire delete_post when trashed posts are automatically deleted?
- What’s the earliest point I can get the queried object ID?
- How do I Make a Theme “plugin-ready”?
- What’s the difference between hooks, filters and actions? [duplicate]
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- Is it possible to create an action hook using do_action() within add_action()?
- How can I hook into existing WordPress Bulk actions?
- Define a function outside a class and call the function using action or filter hook
- Create a plugin to change the action to which a function is hooked
- Modifying values with add_action to be sent to db
- Woocommerce – Hide a Column in Cart Table
- How to redirect to action on custom page within admin section
- Hook to get image filename when it is uploaded
- Which are the hooks run before/after when a category’s deletion?
- Should action callbacks start with a verb?
- Execute Hook on the footer or header after activating a plugin
- Namespaced action and filter tags
- Prefixing plugin hooks (actions/filters) with a wrapper class or functions
- Force HTTPS 301 redirect with hook
- I have 2 plugins using the same wp_login action hook and one is not working
- Add a new confirmation page before saving
- How dynamic action login_form_{action} is working
- What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?
- How to get all queries’s results after they have executed?
- Bug: Post needs to be updated twice when adding action for save_post hook
- When does save_post hook fire on post save/update
- Hook add_attachment error
- Call to undefined function is_home() or any conditional tags
- How to find list of all functions bind to a particular hook from my plugin?
- Can I Hook Into the TinyMCE Insert/Edit Link Button to Use Shortlink For Post?
- Using init hook for register_taxonomy is causing invalid_taxonomy in wp_insert_term()
- Action / Hook when a new plugin is added
- apply_filters() and call_user_func() to define and call a function outside a class
- WordPress Plugin Boilerplate – add actions and/or filters based on user’s role
- remove different admin menu for specific users
- add_option_{$option} action hook not being called
- Does WordPress have something like timer hook?
- Can I use a hook other than ‘init’ to handle form submissions?
- How can I set a dynamic value for post_updated_messages based on return value of post_updated?
- Insert plugin html content to a specific spot in the frontpage
- Apply function on all action hooks?
- Ninja Forms: Front-End Forms, Post ID?
- WordPress Update Plugin Hook/Action? Since 3.9
- Making a plugin file accessible via url rewrite?
- When can you get current page ID and initialize hooks right after?
- add_action with a class method is causing fatal errors
- Is there widely accepted phpDoc syntax for documenting which hook calls a function?
- Which to use to execute code during the saving of a plugin settings page?
- WordPress scheduled task is called but not executed
- Using the ‘draft_to_publish’ hook (post status transition)
- How to modify post content before writing to database?
- How do I handle multiple Submit buttons in plugin’s option page?
- Dynamically Override Fancy Title
- What is the Difference between directly call a function and call a function using add_action?
- How to register custom post types in a plugin?
- Adding Automatically To In WordPress Using Filter Referencing?
- Best Practices for Creating and Handling Forms with Plugins?
- Is there a better way to implement responsive images than what WordPress uses by default?
- Add tab to profile.php wordpress plugin development
- How do I change the initial quantity of a product in woocommerce?
- ‘wp_login’ action hook not working with wp-login.php file
- .mo translation strings not loading in PHP scripts that handle AJAX calls
- Trying to understand order and frequency of action hooks firing
- On cliking add new post redirect user to a custom page first
- Plugin with action ‘save_post’ needs to press publish twice on order to publish
- do_action and add_action on two different installed plugins won’t work
- wp_set_object_terms not updating database without a die()
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- template_redirect or admin-ajax.php?
- Does admin_print_scripts-$hook_suffix work for nested paths to individual files?
- Delete data from database using row action
- Plugin does not add action
- How to replace default comments with custom HTML?
- Is there an admin hook that will let me read GET variable before it’s too late to set the header Location
- Why enqueue styles on hook?
- Hook for page Request?
- WooCommerce change Tax Class programmatically when Recalculating an existing Order [closed]
- Add a check box in Menu Settings
- Hide one specific woocoomerce product
- Include HTML (Bootstrap Modal Box) with a plugin into my header
- Redirect returning users to a certain page?
- Is there any way to pass messages from a script to a redirect target in a hidden fashion?
- Trigger function on Remove block or add new block in Gutenberg JavaScript
- Woocommerce get_term_by() in transition_post_status hook doesn’t works
- Limit get_next_post to posts from the same author
- Where do I hook to have the server do something in PHP on block attribute change?
- Add New Button in Admin Panel
- Any way, hook to add content right before the “read more” link?
- Add a custom submenu under submenu in a Custom WordPress Plugin
- Post is uncatagorized in publish_post action
- How do I ensure I can loop through every enqueued script and CSS?
- replacing jquery google cdn with a new version dynamically
- Unable to show a message after plugin activation
- ‘Conflict’ with action deleted_post and is_admin()
- Redirections the right way inside a plugin directory
- Execute callback after REST API request completes + Response is sent