Using WordPress ‘install_plugin_complete_actions’ PHP filter

The install_plugin_complete_actions WordPress PHP Filter allows you to modify the list of action links available following a single plugin installation.

Usage

add_filter('install_plugin_complete_actions', 'my_custom_function', 10, 3);

function my_custom_function($install_actions, $api, $plugin_file) {
    // your custom code here
    return $install_actions;
}

Parameters

  • $install_actions (string[]): An array of plugin action links.
  • $api (object): An 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.

More information

See WordPress Developer Resources: install_plugin_complete_actions

Examples

Add a custom link to the plugin’s settings page after installation.

add_filter('install_plugin_complete_actions', 'add_custom_link', 10, 3);

function add_custom_link($install_actions, $api, $plugin_file) {
    $install_actions['custom_link'] = '<a href="' . admin_url('options-general.php?page=my-plugin-settings') . '">My Plugin Settings</a>';
    return $install_actions;
}

Remove the “Activate Plugin” link from the list of action links after plugin installation.

add_filter('install_plugin_complete_actions', 'remove_activate_link', 10, 3);

function remove_activate_link($install_actions, $api, $plugin_file) {
    unset($install_actions['activate_plugin']);
    return $install_actions;
}

Modify the “Plugins Page” link text after plugin installation.

add_filter('install_plugin_complete_actions', 'change_plugins_page_text', 10, 3);

function change_plugins_page_text($install_actions, $api, $plugin_file) {
    $install_actions['plugins_page'] = '<a href="' . self_admin_url('plugins.php') . '">Go to My Plugins</a>';
    return $install_actions;
}

Add a custom link after installation only for a specific plugin.

add_filter('install_plugin_complete_actions', 'specific_plugin_custom_link', 10, 3);

function specific_plugin_custom_link($install_actions, $api, $plugin_file) {
    if ('my-plugin/my-plugin.php' === $plugin_file) {
        $install_actions['custom_link'] = '<a href="' . admin_url('admin.php?page=my-plugin-dashboard') . '">My Plugin Dashboard</a>';
    }
    return $install_actions;
}

Remove all action links after plugin installation.

add_filter('install_plugin_complete_actions', 'remove_all_action_links', 10, 3);

function remove_all_action_links($install_actions, $api, $plugin_file) {
    return array();
}