wpexpertsio / password-protected

Password protect your WordPress site quickly and simply
https://wordpress.org/plugins/password-protected/
69 stars 63 forks source link

It would be great to be able to set the password and other plugin settings programmatically (for automated deploy scripts) #145

Closed macolo closed 5 years ago

macolo commented 5 years ago

It would be great to be able to set the password and other plugin settings programmatically.

For example via wp-cli or just via php on the command line.

Use Case: Deploy scripts should be able to install the password protect plugin and then also configure it.

macolo commented 5 years ago

turns out this is super easy. Here is an example in ansible with wp-cli:

# protect stage
- name: configure password protect plugin to protect stage environments
  command: "{{ item }}"
  args:
    chdir: "{{ project_root }}/wordpress/"
  with_items:
    - wp option update password_protected_status 1
    - wp option update password_protected_feeds 1
    - wp option update password_protected_rest 1
    - wp option update password_protected_administrators 1
    - wp option update password_protected_users 1
    - wp option update password_protected_password e4b686c6678333jakfj390sfjdf7493a3ec9 # password is 'password'
    - wp option update password_protected_remember_me 1
    - wp option update password_protected_remember_me_lifetime 60
  become_user: www-data
  when: not wp_blog_public