Przeglądaj źródła

skip email notification on admin password and email change

Girish Ramakrishnan 9 lat temu
rodzic
commit
43e6a76d53
1 zmienionych plików z 5 dodań i 3 usunięć
  1. 5 3
      start.sh

+ 5 - 3
start.sh

@@ -28,7 +28,7 @@ if [[ ! -f "/app/data/.dbsetup" ]]; then
     mkdir -p /app/data/wp-content/mu-plugins
     cp -r /app/code/wp-content-vanilla/* /app/data/wp-content/
 
-    # --skip-email is part of 0.23.0 (https://github.com/wp-cli/wp-cli/pull/2345)
+    # --skip-email is part of 0.23.0 https://github.com/wp-cli/wp-cli/pull/2345 and https://github.com/wp-cli/wp-cli/issues/1164
     $WP --url="${APP_ORIGIN}" --skip-email core install \
         --url="${APP_ORIGIN}" \
         --title="My blog" \
@@ -70,8 +70,10 @@ $WP option update smtp_auth false
 
 # reset the admin password. do this after configuring smtp mail
 echo "Resetting admin password"
-$WP user update $($WP user get admin --field=ID) --user_pass="${admin_password}"
-$WP user update $($WP user get admin --field=ID) --user_email="${admin_email}"
+# see http://wp-cli.org/docs/internal-api/wp-cli-add-hook/ and https://codex.wordpress.org/Plugin_API/Filter_Reference/send_password_change_email
+echo "<?php WP_CLI::add_hook('after_wp_load', function () { add_filter( 'send_password_change_email', '__return_false' ); }); ?>" > /run/wordpress/skip-email.php
+$WP --require=/run/wordpress/skip-email.php user update $($WP user get admin --field=ID) --user_pass="${admin_password}"
+$WP --require=/run/wordpress/skip-email.php user update $($WP user get admin --field=ID) --user_email="${admin_email}"
 
 # configure LDAP
 # https://github.com/heiglandreas/authLdap/blob/master/authLdap.php#L644