• Hi.

    I’m trying to delete one or more plugins from code but I can’t.

    I tried with the function: delete_plugins() but I receive a following error:

    Call to undefined function delete_plugins()

    Someone knows how can I delete specific plugin with code?

    Thanks and regards

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator t-p

    (@t-p)

    Try manually deleting using FTP/ SFTP , or your web-host’s cPanel or whatever file management application your host provides

    Thread Starter Oscar Abad Folgueira

    (@oabadfol)

    Thanks t-p but I want to delete with code.

    Regards.

    Moderator t-p

    (@t-p)

    you are welcome ??

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    show your code — pastebin.com or gist.github.com

    Bunty

    (@bhargavbhandari90)

    function delete_plugin_code() {
    	$plugins = array( 'akismet/akismet.php', 'advanced-custom-fields/acf.php', 'contact-form-7/wp-contact-form-7.php' );
    	delete_plugins( $plugins );
    }
    add_action( 'admin_init', 'delete_plugin_code' );

    I added this code and successfully deleted the plugins. Plugins should be deactivate which you want to delete. If you try to delete active plugin, then plugin will be deleted but it will show error on plugin page like “The plugin XXXX has been deactivated due to an error: Plugin file does not exist.”

    Note: This is just a sample. You need to make your conditions for deleting plugins.

    Thread Starter Oscar Abad Folgueira

    (@oabadfol)

    Thanks, Bunty!!

    Your code works fine.

    Thanks and regards..

    Bunty

    (@bhargavbhandari90)

    Thank You. ?? @oabadfol

    • This reply was modified 7 years, 10 months ago by Bunty. Reason: forgot to mention name
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Delete plugins with code’ is closed to new replies.