Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am looking for a way to activate a WordPress plugin via a SQL query. I am aware you can login and hit "activate" on the particular plugin, but I would like to automate the activation as part of a release process.

I came across this question which makes me think that it may not be possible as the activate plugins are stored in wp_options in a specific format.

I am using a heavily-modified version of WordPress 3.3.1.

share|improve this question
    
What specific format are you talking about? The data has been serialized, that's it. –  t f Oct 1 '13 at 15:15
add comment

1 Answer

If your goal is automated plugin activation you don't have to do it via SQL. You could, of course, but why not use functionality that comes with WordPress?

As I mentioned in my comment, the data has been serialized so you just have to

  • unserialize the data,
  • add your plugin,
  • re-serialize the data,
  • and update the option.

Here is a code snippet for that:

$active_plugins = unserialize(get_option('active_plugins'));
if ($active_plugins && is_array($active_plugins)) {
    $active_plugins[] = 'PLUGIN-DIR/PLUGIN-FILE.php'; // as in 'akismet/akismet.php'
    update_option('active_plugins', serialize($active_plugins));
} else {
    // something went wrong...
}
share|improve this answer
    
How does your solution help to figure out a way to activate a WordPress plugin via a SQL query.? –  Eugene Manuilov Oct 1 '13 at 16:49
    
@EugeneManuilov It does not. However, despite the title reads activate ... via SQL, the question itself asks for an automated plugin activation - and that is exactly what my answer provides... That being said, you're right in that I could/should indicate this in my answer. –  t f Oct 1 '13 at 17:45
    
that's better now ;) –  Eugene Manuilov Oct 1 '13 at 17:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.