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?
- Delete data from database using row action
- flush rewrite rules after plugin update?
- Plugin does not add action
- Remove an action by extending class and replacing it
- Add child pages to submenu automatically
- After plugin activation hook
- How to replace default comments with custom HTML?
- Odd map_meta_cap $args on post edit — sometimes integer, sometimes string
- Trying to get class to instantiate ONCE (or, “why do I keep punching myself in the head?”)
- How can I create a custom plugin that allows anonymous users to signup without registering?
- hook filter after the_content on a specific page
- Bind a function with its own argument to show something dynamically after every content
- A question about add_action()
- 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?
- What’s the hook for filtering every texts of site?
- Hook for page Request?
- WordPress redirect redirecting too many times or not at all
- Associate multiple email addresses with the same user account, so they can log in with either
- WooCommerce change Tax Class programmatically when Recalculating an existing Order [closed]
- Run command “composer install” when activating wordpress plugin
- Update variable value via add_filter
- How to redirect to login page when user not loggedin on a particular page
- Add a check box in Menu Settings
- Custom filter not working
- hook update_option/updated_option empty $old_value and $value
- Configure WordPress to Generate Scheme-less Relative URLs
- Hide one specific woocoomerce product
- Include HTML (Bootstrap Modal Box) with a plugin into my header
- wordpress automatic update does not run
- A good hook to check authorization and redirect?
- Ajax +wordpress onClick link redirect to new page and create html content
- How to replace settings in WordPress plugin from a theme
- Redirect returning users to a certain page?
- What hook to use to redirect based on $post
- Restrict certain actions to plugin-specific admin menu pages only
- How Can I Add Code To A Preexisting Function Without Editing it
- Adding tables to dashboard pages programmatically?
- Setting post_id for single.php based on URL without a redirect
- Is there any way to pass messages from a script to a redirect target in a hidden fashion?
- Creating posts with links from a txt file
- Set the payment processor callbacks to a plugin
- Custom payment method after payment user is logged out on thank you page
- How to do admin ajax request in a plugin for rest api
- Getting Post ID at “stylesheet” and “template” hooks
- Session management issues with WordPRess 404 Error page
- How to enhance a self developed plugin by its own plugin architecture
- Trigger function on Remove block or add new block in Gutenberg JavaScript
- How to update global variables in plugin activation callback?
- Woocommerce get_term_by() in transition_post_status hook doesn’t works
- Add two button to page and post admin to redirect to : add new & list of (posts – pages) just after saving post or page
- `registration_errors` filter doesn’t seem to be called
- How to grab data after wp user search is complete
- Limit get_next_post to posts from the same author