how to activate wordpress plugins internally?

I am creating a small utility which will help to rebuild install.php of WordPress.

What I want to achieve is, when user will install WordPress with this customized install.php, he’ll get some plugins already activated.

Read More

I tried to put these lines at the end of install.php file

require_once('path...wordpresswp-includesplugin.php');
activate_plugin('hello.php');

that activates Hello Dolly plugin but shows error 'invalid datatype for second argument on line 310' for plugin.php

Also, if I try plugins which are inside a folder, for example

require_once('path...wordpresswp-includesplugin.php');
activate_plugin('plugin-folderfile.php');

its not getting activated.
[i’ve tried different combinations for sending arguments, echoing arguments in plugin.php etc. but activate_plugin() does receive correct argument. ]

Consider that plugins are already copied in wp-content/plugins directory.

Whats wrong? Is there any different way to achieve this?

Thanks

Related posts

Leave a Reply

2 comments

  1. Instead of including plugin.php file, include the wp-load.php file

    require_once('path...wordpresswpload.php');
    

    wpload.php will automatically include all the file in the correct order, which should solve your issue.

  2. Atlast I came up with a new activate_plugin function that I added to that file. Problem in old function is the check for active plugins. At first since there is no active plugin, it was returning null value, showing the error. I removed that for my use.

    why we dont see errors when using from wordpress dashboard ? wordpress hides them.

    Thanks anyway..