• I use the following two snippets to prevent usernames from being identified by bots:

    ______________________________________________________________
    Prevent hackers finding usernames 1.0 – Author Query Parameter

    function 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 Endpoints

    function 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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    There’s nothing in the plugin code which should be deleting code from the database randomly. Is it possible that there is another administrator on your site or a piece of security software which is doing this?

    Thread Starter irio114

    (@irio114)

    It is happening on more than 20 different sites on different servers. Each with varying security configs.

    No other admins or security software are causing the issue. Is there a way to generate a log to see what is causing these removals?

    Plugin Author Shea Bunge

    (@bungeshea)

    Does this still happen when the Code Snippets plugin is inactive?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Certain snippets being deleted’ is closed to new replies.