We have this WordPress Network (multisite) running. Many students have a subsite to display their portfolios. We also have a subsite where all students can post a message to promote their portfolio’s. In order to allow them to, we need to have the list of the administrators of all the subsites and add them the role “author” on the portfolios subsite.

Before issuing any commands, make sure you are logged into the server as the user owning the wordpress installation. Change to the public_html directory and check permissions.

cd public_html
ls -al

See that we are the user cloudbr and the web is owned by cloudbr. In case you are root, become the web owner by

su – cloudbr

The wp-cli Code

Of course, make sure you have wp-cli installed on your system. Lets take a look at our command first and then open it up and explain the parts

wp user  list --network --url=$url --fields=ID | xargs -n1 -I % wp user add-role   % author   --url=http://cloudbrug.nl/portfolios/
Screenshot of ssh screen updating wordpress users
Add owners of a subsite to another subsite

Eén gedachte over “Add owners of a subsite to another subsite

Reacties zijn gesloten.