As @MohammadLimon said I need to use the Transients API. The following code worked:
register_activation_hook( __FILE__, 'sp_subscriber_check_activation_hook' );
function sp_subscriber_check_activation_hook() {
set_transient( 'mp-admin-notice-activation', true, 5 );
}
add_action( 'admin_notices', 'sp_subscriber_check_activation_notice' );
function sp_subscriber_check_activation_notice(){
if( get_transient( 'mp-admin-notice-activation' ) ){
?>
<div class="updated notice is-dismissible">
<p>If you are using a caching plugin like W3TC or WP Super Cache make sure to make any pages you wish to protect an exception to the caching!</p>
</div>
<?php
delete_transient( 'mp-admin-notice-activation' );
}
}
Related Posts:
- Problems with autoloading classes via sp_autoload_register / maybe interfering WP-specific autoloader
- How to remove duplicate sub-menu name for top level menu items in a plugin?
- category_name not working (not showing up in sql query debug)
- How can I make my custom shortcode work in a Custom HTML Widget?
- How to Loop Plugin Option Field Set?
- Update Multiple Post Meta for the Same Post In One call?
- How do I configure WordPress to talk to a Microsoft SQL Server database?
- Rename existing old uploaded images containing accented French characters (not during upload)
- How to Create a Directory in a Plugin Folder?
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- Create plugin that works in background
- Checking for user role in a custom plugin
- HELP: Integrating WP with raw PHP code once published button is hit
- Loading class files via autoload method
- I would like to use create a function in my custom plugin to tell WP to use a different header
- Getting media library popup in custom plugin admin page
- jQuery function didn’t work in my plugin
- Sanitizing, Validating and Escaping in WordPress (Plugin)
- Escape when echoed
- Write to / remove from default .htaccess file from plugin?
- Plugin Development sqlite or WordPress’ database
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- WooCommerce get_price returning wrong price when used via ajax
- Open Post Thumbnail in New Child Theme File in WordPress
- Programatically download a plugin
- Redirecting to home page after login as custom role WordPress
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- How would I go about creating a user ranked post popularity page?
- What are the specifics of WordPress development I need to know? [closed]
- Redirect to another page using contact form 7? [closed]
- Create a plugin from within WordPress
- Class variables not correct on page
- Why is one phpunit test throwing an error on one class when all other classes are similar without error?
- Activate my plugins via FTP
- Duplicate results are displayed in a custom plugin [closed]
- Why is my custom post type not being activated on plug-in activation?
- How to add apply_filter for a class property in plugin
- How to redirect to same page after form submission
- A server-side hook failed when committing plugin code to SVN
- Content-Security-Policy Headers are there and showing the correct settings, but still getting a refused connection
- How do I add $_SESSION[”] to my wordpress page?
- I receive taxonomy id
- output html on post or page from custom plugin [closed]
- Loop in elementor custom widget not working
- Built a second plugin but it overwrote the first one
- Creating a functionality plugin to edit seriously simple podcasting
- Asynchronous request in wordpress
- How to delete all categories programatically?
- How to use custom Javascript code inside a plugin?
- Make plugin php file called directly aware of WordPress?
- Way to send multiple values for column to MySQL?
- Using meta_query in a WP_Query not working for numbers properly
- Next Previous Post in wordpress with previous / next link with title?
- Different registration form for different roles
- Apply html elements in php statement
- WordPress Post HTML after Posting
- Settings options not showing up on Sub Menu page in WordPress plugin
- Conditional delete metadata does not works
- How can we get this dynamically as this folder may not be by the same name always → wp-admin
- The Build menu theme is frozen with the wordpress theme
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- How can I translate something in my class constructor of my plugin in WordPress?
- Define global variable in theme file and call that variable in plugin file
- Why is my shortcode not working?
- Rename a folder via HTML POST request
- How to translate to spanish wordpress hardcoded content/files?
- Getting Fatal error: Uncaught Error: Call to undefined function plugin_dir_path() when linking to another file within my wordpress plugin
- working code, not working – Plugin Dev
- SimpleXML is not working with xml response from external api
- WordPress plugin blog creation
- Multiple image selection custom widget
- implement checkbox or toggle switch in plugin code
- Prefix WordPress Taxonomy Tags With Hashtag Symbol Like Twitter
- Change Woo Custom Endpoint Titles from a Plugin
- submit form data to wordpress existing database table using my plugin
- register_activation_hook doesn’t fire at all
- My ajax request don´t work and return 0
- Populate select option with JSON file
- How can I insert a record into a custom table from my custom form in my custom admin page?
- Plugin Breaking WordPress Login
- How to get site homepage from plugin?
- Can anyone tell me why I can’t edit a plugin when it is installed without having to re-install?
- Unable to show 4 products in a row
- How to fix ‘Call to undefined function do_settings()’ error?
- What is the source outline for a basic word press plugin?
- Submit posts in two different post types with the same form
- how to search through plugin in wordpress cimy-user-extra-fields?
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- How to override plugin function in code snippets WordPress
- How to create a “Most Popular” & “Latest” TAB in WordPress
- WordPress Throwing Deprecated Errors on its own Files
- Use inline callable for hooks and filters
- Error in using ‘admin_enqueue_scripts’ action through a class
- plugin doesn’t retrieve data from database
- Mixed results with is_page() WordPress function, when using $this, or self
- REST API – filters not working inside plugin class
- WordPress site server getting blocked due to resource abuse
- Remove H1 title in admin post edit screen
- Custom Search Function in WordPress Returns No Results