Certain snippets being deleted
-
I use the following two snippets to prevent usernames from being identified by bots:
______________________________________________________________
Prevent hackers finding usernames 1.0 – Author Query Parameterfunction redirect_to_home_if_author_parameter() {
$is_author_set = get_query_var( ‘author’, ” );
if ( $is_author_set != ” && !is_admin()) {
wp_redirect( home_url(), 301 );
exit;
}
}
add_action( ‘template_redirect’, ‘redirect_to_home_if_author_parameter’ );
______________________________________________________________
Prevent hackers finding usernames 2.0 – JSON REST Endpointsfunction disable_rest_endpoints ( $endpoints ) {
if ( isset( $endpoints[‘/wp/v2/users’] ) ) {
unset( $endpoints[‘/wp/v2/users’] );
}
if ( isset( $endpoints[‘/wp/v2/users/(?P<id>[\d]+)’] ) ) {
unset( $endpoints[‘/wp/v2/users/(?P<id>[\d]+)’] );
}
return $endpoints;
}
add_filter( ‘rest_endpoints’, ‘disable_rest_endpoints’);
________________________________________________________Both snippets activate without issue, but will be deleted from the snippets list after a few hours. I was hoping you could shed a bit of light on the situation.
- The topic ‘Certain snippets being deleted’ is closed to new replies.