Is it possible to set a option, and then redirect to another page directly from a admin notice link?

You could use /wp-admin/admin-post.php. Link: $url = admin_url( ‘admin-post.php?action=somethingunique’ ); print “<a href=”https://wordpress.stackexchange.com/questions/85825/$url”>Update and redirect</a>”; Then you should register a callback for that action: add_action( ‘admin_post_somethingunique’, ‘wpse_85825_callback’ ); And in that callback you can do what you want: function wpse_85825_callback() { if ( current_user_can( ‘manage_options’ ) ) update_option( ‘my_option’, ‘some_value’ ); wp_redirect( admin_url( ‘users.php’ ) … Read more

admin_notices after register_uninstall / deactivate_hook

The short answer is no, it is not possible. When you deactivate your plugin, it’s deactivated so doesn’t run your admin_notices action when the admin screen is refreshed. You can confirm it for yourself by using the action in a slightly different way. In your deactivation function include the following line: set_transient(‘my_deactivation_transient’, ‘My plugin is … Read more

Add custom post notice after post delete

Checking the bulk counts We can check the bulk counts, to see if any post was deleted: add_filter( ‘bulk_post_updated_messages’, function( $bulk_messages, $bulk_counts ) { // Check the bulk counts for ‘deleted’ and add notice if it’s gt 0 if( isset( $bulk_counts[‘deleted’] ) && $bulk_counts[‘deleted’] > 0 ) add_filter( ‘admin_notices’, ‘wpse_243594_notice’ ); return $bulk_messages; }, 10, … Read more

Undefined property: stdClass::$labels in general-template.php post_type_archive_title()

This is a bug (one that I’ve encountered before) and could do with a ticket in trac (since I never took the time to submit one!) The trouble starts with requests that set multiple is_* query flags as true (specifically flags that represent objects, such as single posts, pages, and post type & term archives). … Read more

register_sidebar notice [closed]

Find file where is register_sidebar ( must be on theme folder or plugins ) add ID to sidebar register_sidebar( array( ‘name’ => __( ‘Main Sidebar’, ‘theme-slug’ ), ‘id’ => ‘change_me’, // Add only this line ‘description’ => __( ‘Widgets in this area will be shown on all posts and pages.’, ‘theme-slug’ ), ‘before_widget’ => ‘<li … Read more

WordPress admin notice in plugin function

Your problem is pretty simple. Your callback for this hook is not a simple function but some method of a class. If you add action like this: add_action(‘admin_notices’, ‘simple_notice’); you tell WP that there is some simple function called simple_notice and it should be called when hook admin_notices is processed. But… There is no such … Read more

How to customize post edit notices

You can used the post_updated_messages filter. add_filter( ‘post_updated_messages’, ‘rw_post_updated_messages’ ); function rw_post_updated_messages( $messages ) { $post = get_post(); $post_type = get_post_type( $post ); $post_type_object = get_post_type_object( $post_type ); $messages[‘my-post-type’] = array( 0 => ”, // Unused. Messages start at index 1. 1 => __( ‘My Post Type updated.’ ), 2 => __( ‘Custom field updated.’ … Read more

How to Make an admin_notices Message That Disappears Once the User Leaves That Particular Page?

The short answer is: Use Query Strings. If you notice in the address bar immediately after you publish a Post… You will see something similar to this: domain.com/wp-admin/post.php?post=4935&action=edit&message=6 There’s a few different Query Variables: post contains the ID of the Post being edited. action is saying we’re currently “editing” the Post. message refers to what … Read more

Hide php Notices in Dashboard

I don’t know how to move the notices to the bottom or if that’s possible at all. To disable the debug mode in wp-admin write in wp-config.php: define( ‘WP_DEBUG’, FALSE === strpos( $_SERVER[‘REQUEST_URI’], ‘/wp-admin/’ ) ); Untested: You could try to enable warnings in admin with: // happens early in wp-admin/admin.php add_filter( ‘secure_auth_redirect’, ‘wpse_67728_error_warnings’ ); … Read more