WordPress Bulk Actions with WP-CLI

I manage a WordPress Multi-user environment and needed to bulk add LDAP users (which is already quite easy) and also to bulk create blogs for users – which I couldn’t find an easy method for. I started exploring how I could script the creation of this when I happened upon WP-CLI.

Then to install WP-CLI:

You should see the following output:

Then you should manually add the following to your .bash_profile so that the ‘wp’ command can be found without entering the full path to it.

Go to the directory that WordPress is installed in and run:

You should see the currently installed version output.

I run a WordPress Multi-user environment so wp-cli would be of most use when creating bulk sites. A single site can be created as follows:

That would create a site http://blogs.domain.uk/mynewsite with the user jonny@domain.uk as the administrator. Dozens of sites can then be created be feeding a list into a shell script.

What I need next is the ability to add a particular (supervisor) user as an administrator to a bulk list of blogs. I can do it with built in users e.g.

But this does not appear to work with my LDAP linked users ๐Ÿ™

So I manually created a script to output the SQL to produce output for each site as follows;

The script:

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">