This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
install_plugin_complete_actions filter
If you’re diving into WordPress development, you’ve probably come across hooks. Hooks are a way to change or add to the behavior of WordPress without editing the core files. Today, we’re talking about the install_plugin_complete_actions filter. This filter lets you modify the list of action links available after a single plugin installation. Let’s get started!
To use the install_plugin_complete_actions filter, you first need to register it using add_filter. You can place this code in the functions.php file of your active theme or in a custom WordPress Plugin. At WePlugins, we always prefer creating a custom WordPress Plugin when using hooks. This way, nothing breaks when you update your WordPress theme in the future.
Parameters
- $install_actions: (string[]) Array of plugin action links.
- $api: (object) Object containing WordPress.org API plugin data. Empty for non-API installs, such as when a plugin is installed via upload.
- $plugin_file: (string) Path to the plugin file relative to the plugins directory.
Below are the 3 parameters required to use this hook:
Live Examples
Example 1: Adding a Custom Action Link
In this example, we’ll add a custom action link to the plugin installation actions.
function weplugins_add_custom_action_link($install_actions, $api, $plugin_file) { $install_actions[] = '<a href="https://weplugins.com">Visit WePlugins</a>'; return $install_actions; } add_filter("install_plugin_complete_actions", "weplugins_add_custom_action_link", 10, 3);
Example 2: Removing an Action Link
This example demonstrates how to remove a specific action link from the plugin installation actions.
function weplugins_remove_custom_action_link($install_actions, $api, $plugin_file) { if (($key = array_search('activate_plugin', $install_actions)) !== false) { unset($install_actions[$key]); } return $install_actions; } add_filter("install_plugin_complete_actions", "weplugins_remove_custom_action_link", 10, 3);
Example 3: Conditional Action Links
In this example, we’ll add action links conditionally based on the plugin being installed.
function weplugins_conditional_action_links($install_actions, $api, $plugin_file) { if ($plugin_file == 'my-plugin/my-plugin.php') { $install_actions[] = '<a href="https://weplugins.com/special">Special Link</a>'; } return $install_actions; } add_filter("install_plugin_complete_actions", "weplugins_conditional_action_links", 10, 3);
To remove a hook callback, use the example below:
remove_filter("install_plugin_complete_actions", "modify_install_plugin_complete_actions_defaults", 10, 3);
Please make sure to provide the same callback function name, priority, and number of arguments while removing the hook callback.
Contact Us
If you need any customization or run into any issues while using this hook, feel free to contact us at WePlugins. We’re always here to help you out!
Explore the latest in WordPress
Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.