Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/wp-login.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@
/** Make sure that the WordPress bootstrap has run before continuing. */
require __DIR__ . '/wp-load.php';

/**
* Prevents user registration if the 'users_can_register' option is disabled.
*
* This function checks if user registration is disabled (`users_can_register` = 0)
* and blocks access to the registration page (`wp-login.php?action=register`) by

Check failure on line 18 in src/wp-login.php

View workflow job for this annotation

GitHub Actions / PHP coding standards / Run coding standards checks

Whitespace found at end of line
* displaying an error message.
*
* @since 6.7.1
*/
function disable_wp_registration() {
if ( ! get_option( 'users_can_register' ) && isset( $_GET['action'] ) && 'register' === $_GET['action'] ) {

Check failure on line 24 in src/wp-login.php

View workflow job for this annotation

GitHub Actions / PHP coding standards / Run coding standards checks

Tabs must be used to indent lines; spaces are not allowed
wp_die(

Check failure on line 25 in src/wp-login.php

View workflow job for this annotation

GitHub Actions / PHP coding standards / Run coding standards checks

Tabs must be used to indent lines; spaces are not allowed
apply_filters( 'disable_registration_message', __( 'Registration is disabled on this site.', 'default' ) )

Check failure on line 26 in src/wp-login.php

View workflow job for this annotation

GitHub Actions / PHP coding standards / Run coding standards checks

Tabs must be used to indent lines; spaces are not allowed
);

Check failure on line 27 in src/wp-login.php

View workflow job for this annotation

GitHub Actions / PHP coding standards / Run coding standards checks

Tabs must be used to indent lines; spaces are not allowed
}

Check failure on line 28 in src/wp-login.php

View workflow job for this annotation

GitHub Actions / PHP coding standards / Run coding standards checks

Tabs must be used to indent lines; spaces are not allowed
}
add_action( 'init', 'disable_wp_registration' );

// Redirect to HTTPS login if forced to use SSL.
if ( force_ssl_admin() && ! is_ssl() ) {
if ( str_starts_with( $_SERVER['REQUEST_URI'], 'http' ) ) {
Expand Down
Loading