WordPress Read Only
Here’s how to create a WordPress site that’s read only. You will not be able to create, update and delete posts.
- Login to MySQL or MariaDB.
- Choose mysql database.
- Create a new user called ‘wpro’ for WordPress read only.
- Grant select permissions to all tables in ‘wordpress’ database.
- Flush privileges to commit your changes.
<pre lang="bash">
mariadb -u root -p
use mysql;
create user 'wpro'@'localhost' identified by 'yourpassword';
grant select on wordpress.* to 'wpro'@'localhost';
flush privileges;
In MySQL or MariaDB, you have to terminate all commands with a semicolon.
Now edit your WordPress wp-config.php file. vim /var/www/wordpress/wp-config.php.
<pre lang="bash">
/** MySQL database username */
define('DB_USER', 'wpro');
/** MySQL database password */
define('DB_PASSWORD', 'yourpassword');
After saving the wp-config.php file, everything should work just like before, except that you will not be able to save, publish or delete posts, pages, or add or delete media files to your WordPress site. It’s working as intended.