It’s impossible, because after deactivation your theme isn’t even loaded!
It’s possible, but hacky. Essentially, we unset the action
param, load in the themes admin page & then exit before the redirect-on-success occurs.
add_action( 'switch_theme', 'wpse_60972_theme_deactivate_message' );
function wpse_60972_theme_deactivate_message()
{
$msg = '
<div class="error">
<p>Your theme has been DEACTIVATED</p>
</div>';
add_action( 'admin_notices', create_function( '', 'echo "' . addcslashes( $msg, '"' ) . '";' ) );
unset( $_GET['action'] );
require ABSPATH . 'wp-admin/themes.php';
exit;
}
If the code you posted is verbatim, may I ask why you want do as such? WordPress has it’s own notices for activation & deactivation.
Related Posts:
- How to trigger function on theme delete?
- What hook is the currently active theme’s functions.php file loaded on? [duplicate]
- How to switch theme if the current user is admin?
- get_template_part vs action hooks in themes
- Any official way to create an admin theme?
- How do I create my own admin button and theme settings page?
- How can I log a user out of WordPress before the page loads?
- Check php version before theme activation
- Display a different theme for not logged-in users
- What’s the earliest point I can get the queried object ID?
- How can I remove “Proudly powered by WordPress” from twentyeleven without modifying footer.php?
- Remove action within a class in a parent theme from the child theme
- Use latest jQuery in WordPress (admin interface)
- Exclude stylesheet from admin
- Filter or action hook to insert content on admin pages before tag
- How get Themes list via REST api?
- Activate a new WordPress Theme Only for Admins
- Delete database tables on theme uninstall?
- How can I show more than 15 themes at a time in the admin menu?
- How to load a different theme for categories?
- add_action in functions.php, do_action in plugin?
- How do you get thumbnails to show up in the admin edit post?
- Theme Development Admin Area [closed]
- Posts and Pages not showing on admin, but showing in theme
- Trigger a custom function when option are saved in admin area
- How can I add class to every quote element?
- Redux callback action
- Switching content between summer and winter
- How can we hide the parent’s theme url at the child themes details on a multisite?
- after_setup_theme is called three times
- It’s okay if I do not write add_action()
- Is it good practice moving the main stylesheets after the plugin styles?
- Use remove_meta_box conditionally on custom post type
- How to get menu location in wp_update_nav_menu hook
- How do I add some javascript validation to the admin interface form’s onsubmit?
- Translate a site based on different themes
- Passing dynamic options from backend to frontend
- Problems to disable the comments for my statics pages
- How to reset a custom theme
- Theme javascript/css 404
- Can not add admin notices from the edit_user_profile_update hook (notices not being displayed)?
- Can I easily switch themes on a fully built website? [closed]
- Switching Theme and back will reset the previous Theme’s settings?
- How to include stylesheet in custom admin using parent_slug
- I made new theme directory, why won’t it show up in admin GUI?
- Fix warning: Missing argument
- Is there any way to modify images from a theme using the web interface?
- Can we change the hook firing sequence?
- Set custom directory in theme for page templates
- Hooking into the HTML header container
- Webflow Interactions on WordPress site?
- Don’t prepend WordPress base url to image paths
- Ensure Quality Transition to New WordPress Theme [closed]
- wp_login_form() ignoring login_form action hook
- ‘Conflict’ with action deleted_post and is_admin()
- Warning: call_user_func() expects parameter 1 to be a valid callback
- Are immediately-called actions not usable in themes?
- How to allow users to switch to the child theme from front end without plugin?
- How to remove the option data of a theme when that theme is removed?
- Where can I find the “add_action()” inside a theme?
- Adding a wp_head hook from an included PHP file
- Fatal error Class-wp-hook, again, but not sure what’s triggering it
- Remove 3rd party plugin notices from within own plugin
- Hook from plugin doesn’t fire up from external PHP script
- Problem of not changing the front and bottom of the Woodmart template by activating the really simple ssl pro plugin in WordPress
- Please help me clear my confusions about WordPress
- WordPress 2022 template, how to see the blocks added in post template on post edit?
- Two themes using a Multiple Themes plugin
- Action / Hook when a new plugin is added
- Why does an ad page open when I browse my websites’s wp-admin page?
- Transclude/Import one wordpress page to another
- changing genesis_before_while in new theme framework
- apply_filters() and call_user_func() to define and call a function outside a class
- Get the name WordPress default theme in the core
- How to push a theme update for a ciustom theme used on multiple independant self hosted sites?
- brand section in wordpress lost after change theme
- Pharmacare theme login page / login modal redirection to custom URL
- Is it a good idea to make WordPress theme repository public?
- Rewrite the search page to use an appended slug + parameter
- Getting Post ID at “stylesheet” and “template” hooks
- Session management issues with WordPRess 404 Error page
- Remove admin sub menu from child theme
- Trying to revive an old wordpress site, but newer versions of wordpress install a different db structure
- Using `set_transient()` when saving a custom post type
- How to call do_action() to pass arguments to hooked functions that take different number of args?
- Can I use non-wordpress themes in WordPress?
- Using publish_{custom-post-type} hook for custom post type to update meta doesn’t work
- Setting Multiple Post Containers Across Homepage And Costumize Them
- Removing basic header/text elements from a theme
- How to add image from theme files to media library after theme activation?
- Is bloginfo(‘template_directory’) generated based on WP_SITEURL and WP_HOME in the settings?
- Flexslider in child theme
- Load elements without reload page [closed]
- Is there a way to know when a page has been updated and do some action only once?
- Broken theme, stylesheet is missing after uploading the right theme via FTP
- What is the correct way to set up a staging server and use github for version control?
- style_loader_tag not changing stylesheet to preload
- How do I use the default style for widget?
- WordPress fails to embed video URL on specific theme
- How to validate new added field (Phone number) which is added to registration form?