Skip to content

Commit d0a3d16

Browse files
committed
Make account creation hook independent of wp-admin page
1 parent 3d84794 commit d0a3d16

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

wp-config-sample.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,16 @@
6464
/** Sets up WordPress vars and included files. */
6565
require_once __DIR__ . '/wp-settings.php' ;
6666

67-
add_action( 'login_init', function () {
67+
// Auto-create an admin account for local development
68+
//
69+
// https://codex.wordpress.org/Plugin_API/Action_Reference
70+
//
71+
// The 'init' and 'wp_loaded' hooks would be great hooks for this purpose
72+
// if this code was in any other file (e.g. theme or plugin). Here in
73+
// wp-config.php, add_action is either undefined (before wp-settings.php),
74+
// or it's too later as those those hooks *just* fired at the end of
75+
// the wp-settings.php file. So, instead, just call it directly.
76+
function jquery_dev_autocreate_dev_admin() {
6877
$username = 'dev';
6978
$password = 'dev';
7079
$email = 'dev@localhost';
@@ -76,4 +85,5 @@
7685
'role' => 'administrator',
7786
] );
7887
}
79-
} );
88+
}
89+
jquery_dev_autocreate_dev_admin();

0 commit comments

Comments
 (0)