More importantly you should notice what link is produced by get_delete_post_link()
. It’s an admin link is_admin()
check will be always true
. Instead you need something else that helps match the request. Try adding and query arg to your delete link.
add_query_arg( 'origin', 'fe', get_delete_post_link( get_the_ID() ) );
then in the action
add_action('deleted_post', 'woffice_trashed_post_handler', 10);
function woffice_trashed_post_handler($post_id) {
if( isset( $_POST['origin'] ) && $_POST['origin'] == 'fe' ) {
wp_redirect( get_option('siteurl') );
exit;
}
}
Related Posts:
- Use latest jQuery in WordPress (admin interface)
- Which hook should be used to add an action containing a redirect?
- How to pass parameters to admin_notices?
- Are there any action like ‘init_frontend’
- Make A WordPress Page Accessible To Admins Only, Redirect Other User Roles
- Redirect Admin User in Dashboard
- How can I log a user out of WordPress before the page loads?
- Is there a hook to put stylesheet and/or JS inside iframes (thickbox or tinyMCE) in admin area
- A similar hook as wp_head for the admin area
- Redirect logged in users if they are on a specific page
- after login that will redirect user role into a page
- How to Remove the “Restore” Link in Quick Edit?
- Redirect users on specific post category or category page
- Filter or action hook to insert content on admin pages before tag
- remove_action with profile_personal_options
- how to redirect to url.com/wp-admin if url.com/admin is typed in?
- Adding markup to column text in “Edit Pages” admin page
- Change the Default Pages Menu View in wp-admin
- Disable HTML (Text) Tab in Post Editor
- Admin: global $post empty
- Admin page redirect to another admin page
- Manage users custom column add class “num”
- Custom Thickbox Broken on Dashboard Page?
- Where should I hook into admin?
- Trigger a custom function when option are saved in admin area
- WordPress Admin Login Redirect Problem
- Problems with WP_List_Table and hooks
- How to display message (with switch_theme hook) after deactivating My theme?
- Redirect in an Admin page
- Redirect from the dashboard to edit.php if wp_is_mobile() is true
- Why can’t a custom postype be registered with “admin_init” hook?
- Remove Permalink From Admin Edit Post
- Show excerpt if no title in admin view
- Seems that admin_post_{action} does not executing
- get_current_screen and the WP_Screen class
- How to pass multiple parameter in add_action()
- Use remove_meta_box conditionally on custom post type
- Hide post title input for all roles except admin
- How do I add some javascript validation to the admin interface form’s onsubmit?
- Filter WooCommerce Orders
- Can’t login to my admin area
- WordPress redirect redirecting too many times or not at all
- Can not add admin notices from the edit_user_profile_update hook (notices not being displayed)?
- Send admin to a different login than users?
- Redirect public site to another one but allow administrators to access the old site
- Other than save_post any other actions on add / edit post screen?
- A good hook to check authorization and redirect?
- What hook to use to redirect based on $post
- Remove iPhone detection on login page
- Can we change the hook firing sequence?
- Show only content in page after action click in WordPress admin
- Find out if post was just updated on post edit screen
- Form submit in admin does not set is_admin() true
- Which method to use when deleting posts from the front-end
- Unsure how to add simple checkboxes that write to a small table to admin
- WP Logs me out after updating anything on dashboard
- Remove 3rd party plugin notices from within own plugin
- require/include php file in add_menu()
- I can’t access login page
- Cannot access wp-admin after installing SSL – user capabilities not being set
- Admin Bar Acting Up
- Hook into all password resets in WordPress and get password before hashing?
- Show admin bar to editors with Buddypres
- Trying to hide a submenu link which is created by Co-authors Plus plugin
- {status}_{post_type} does not run correctly?
- When would it be best to hook AJAX functions on a back-end page?
- WP administration over SSL using different domain
- Create WordPress Menu Item Without Linking to a Custom Page
- How to store additional data that is related to core data
- remove_action – pre_get_posts – does not restore original query
- taxonomy_edit_form_fields output after term fields
- Admin Access for specific page(s)
- Trying to login to my site redirects me to the first page
- How can I restrict ‘edit_form_after_’ to a specific post/page?
- remove different admin menu for specific users
- Check if front page within function passed to action
- How can I insert custom html code inside a div dynamically?
- Redirect non-admin after login, and in url – /admin
- Where to store publicly-accessible files
- How to trigger click events using hooks
- Hide top admin panel for non admin and non editors
- Why function called by admin-ajax executes synchronously?
- Blank WordPress admin/dashboard (7 updates pending)
- Search Only Works when Logged into Admin
- Can you check if https is enabled on frontend from admin
- Get Link of Page Selected through a Select Field in Custom Admin Page
- Check get_post value after wp-admin login
- When admin approves a registered user, I don’t want to send a notification email to users
- Can’t access dashboard after 4.8.1 automatic upgrade
- How can I create multiple different admin roles with their own capabilities
- Identify if the_post hook is being called from the admin post list
- Admin hook after editing an image?
- Hooks with same priority number. Can one stack items returned in divs, position: absolute each with their own z-index?
- add instructions to upload pages and / or forms
- Which action hook to update custom field at network/site-info.php in multisite on update site info
- Grab meta data before post is saved
- WordPress hooks to call a function inside a construct
- Sortable admin columns by 0.00 number
- add_option_{$option} action hook not being called
- Can add_image_size be added earlier