You can read more about the details of activation on this answer.
Basically you need to hook a function to register_activation_hook()
– assuming, that this is from within your main plugin folder and not a subfolder:
register_activation_hook( __FILE__, 'on_activation' );
function wpse65190_on_activation()
{
// Add an admin notice:
add_action( 'admin_notices', 'wpse65190_on_activation_note' );
// Then you should check the DB option:
$plugins = get_option( 'active_plugins' );
if ( ! in_array( dirname( __FILE__ ), $plugins )
{
unset( $plugins[ dirname( __FILE__ ) ] );
update_option( 'active_plugins', $plugins );
}
}
function wpse65190_on_activation_note()
{
// Add your note here: Maybe a form?
}
It’s as easy as that. You just have to fill in the gaps. If you got a full working example, please update this answer with your working code. Thanks.
Related Posts:
- Plugin Deactivate Self on Activation Errors
- Is any information available in PHP files in WP about plugin activation history?
- Uninstall, Activate, Deactivate a plugin: typical features & how-to
- How To Activate Plugins via Code?
- Activate a plugin through PHPMyAdmin or FTP?
- Delete tables from database when deleting plugin
- How to check if a theme is active?
- Pluggable function and activation check?
- Automatically install wordpress plugin at theme activation
- Function to activate WordPress theme inside a plugin
- Activate Plugin which is in subfolder?
- explanation for activate_plugin function in wordpress core
- Remote plugin activation hook
- Force plugin to fail activation
- WordPress register_activation_hook table creation not working
- Multisite: Activate plugin for subsites only?
- The plugin generated x characters of unexpected output, $wpdb not defined
- Correct way to use register_activation_hook
- Cannot run the code after I activate the plugin
- Why does deactivating a plugin cause error: “You do not have sufficient permissions to access this page”?
- Many plugins making WordPress run slow by design?
- wordpress in nginx docker container connected to php:8-fpm container and mariadb container isn’t creating any tables on plugin activation
- Unable to activate wordpress importer after installing it
- How to include plugin without activation?
- Auto add content such as pages upon plugin activation?
- Detect when any plugin is activated or deactivated
- How to automate wordpress plugin activate and deactivate by php logic?
- Default Plugin Settings Not Writing to Database
- Plugin won’t activate – cannot declare class (already in use)
- How to activate plugins for my WordPress sites from a remote server
- register_activation_hook with include file [closed]
- Prevent a plugin from being automatically activated
- Activated plugin is stored as an object, rather than as a path
- Own plugin corrups plugin-activation
- How to check if tables in WordPress still exists after activations
- How to block plugin activations with no known user or coming from unknown IP address range?
- Run plugins only on certain pages
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- Force file download on plugin activation
- WordPress user account activation
- Multiple instance of data in plugin custom database table on plugin activation
- Why this function not working for install database on plugin activation
- register_activation_hook in oop approach
- How to create multiple database tables on plugin activation?
- Run function on plugin activation before plugin is loaded
- A question about register_activation hook
- rewrite_rules() not applying rules on plugin activation only after permalinks menu is clicked
- register_activation_hook() not working as expected
- Sub Plugin deactivation when Parent Plugin deactivate
- Advanced WordPress plugin activation detection
- Does Deactivating a Plugin Help Anything?
- Apparent errer when installing plugin
- Activate a plugin via a SQL query
- My plugin does not install correctly if a previous version is still installed
- Is there existing plugins to “Click-to-Launch” embedded Flash / SWF content?
- Activation flow of a plugin in a multisite environment
- How to run flush_rewrite_rules on activation after i register my custom post type using WordPress Boilerplate Plugin
- How to check for already existing plugin versions on activation? and prevent errors
- how to enable/activate a plugin per Cpanel
- My WordPress activation hook isn’t working
- Cannot modify header information – headers already sent during plugin activation
- Unable to to self-deactivate plugin using deactivate_plugins()
- Error Copying Directory On Plugin Activation
- WordPress hook source
- API calls on plugin activation or init?
- All plugins deactivated. What could cause this?
- Different plugins activated online and offline
- Problems with installing and deleting plugins
- Plugin De/Activation Not Firing On MultiSite install
- Custom Table doesn’t create on plugin activation
- Activate plugins by a theme’s functions.php?
- Is it possible to send user new password after they clicking on forgot password in word press
- why i cannot see some plugins while they are enabled on network admin page?
- Install theme as part of a plugin
- Automatically install bundled plugins during theme activation?
- How to disable pagination in WordPress’ API results?
- Is it a good idea to restrict the REST API
- WordPress Plugin translation not working EN To FR
- Redirect OLD/Path to NEWURL/Path
- Adding “Changelog” as a second tab to the auto updater custom plugin
- How can I use the zip of my plugin in another website?
- When to store store plugin options as a single database record?
- Executing ACF field as a shortcode
- Best approach to change mobile background image and adding its class
- Including Google Map within a wordpress plugin
- wp db request without refreshing the page
- WordPress broken dashboard with ninja-shell text
- Is Nonce Verification (CSRF) required for WordPress Custom Bulk User Actions?
- Schedule WordPress plugin activation and / or deactivation on a custom date and time, how to do?
- How to restrict the unauthorized software download
- Can’t change login logo & css – older plugin data blocking?
- List Hidden Plugins
- Gravityforms login form custom redirect if form not submitted
- WordPress hack code issue, help required
- show_admin_bar filter not called inside plugin class
- REST API – filters not working inside plugin class
- Learnpress FATAL ERROR
- Read page- or post-content across different builder-plugins
- WordPress 6.3 headers already sent error
- Advanced Custom Fields (ACF) and their Javascript API