Skip to main contentSkip to footer

Redirecting email searches to the login page

A client asked for a solution to redirect all searches for email addresses to the login page – perhaps someone is constantly using the search field when they’re actually looking for the login.

This can be achieved with the Redirects tool, as it takes regular expressions. You can also add this to your site:

add_action( 'template_redirect', 'rlv_redirect_emails' );
function rlv_redirect_emails() {
    if ( filter_var( get_search_query(), FILTER_VALIDATE_EMAIL ) ) {
        if ( wp_redirect( 'https://www.example.com/wp-login.php' ) ) {
            exit();
        }
    }
}

This function would redirect all queries that look like email addresses (based on RFC 822, with some caveats) to the login page on example.com.

There’s nothing Relevanssi-specific about this, this same function will work with any search solution that isn’t an AJAX search.

Your account

Not logged in. Log in to see your license details.

Search

Popular Resources

Proximity sorting

…post. You give the location with the relevanssi_proximity_coordinates filter hook, which filters the coordinates and gets the post ID as the parameter. Often the coordinates are in a custom field. The necessary function will look something like this: add_filter( ‘relevanssi_proximity_coordinates’, function( $coordinates, $post_id ) { return get_post_meta( $post_id, ‘coordinates’, true……on the relevanssi_proximity_comparison filter hook. That function should return the coordinates as a string. If you don’t use the coordinates query variable, you need this snippet to remove a PHP warning: add_action( ‘init’, function() { remove_filter( ‘relevanssi_search_params’, ‘relevanssi_pick_up_coordinates’ ); } ); Then you need to provide the coordinates for each……a fixed spot or something the search user provides. Relevanssi looks for this in the coordinates query variable and it should have the coordinates in the “latitude, longitude” format. If this is not possible or easy, you can also provide the coordinates with a filter function. Add a filter function…

Why is a post type excluded from search?

…is registered has not changed: it’s still the same. Relevanssi just doesn’t care about it and still indexes the post. The setting does affect Relevanssi in that when Relevanssi does search posts, Relevanssi does respect this setting and will exclude these posts from the searches. That’s often for the best;…In the list of post types to index in the Relevanssi indexing settings tab there’s a column “Excluded from search”, which has a value of “yes” or “no” for each post type. What does this mean, and why does the value remain “yes” even if you set Relevanssi to index……that post type? This column is strictly for information only, and does not govern what Relevanssi does. This is something that is defined when a post type is registered. Some post types are meant for public use (like post or page) and thus are not excluded from the search. Other…

Indexing HTML comments
By default, Relevanssi does not index HTML comments inside your posts. Relevanssi removes all HTML tags before indexing, and HTML…

Related Posts:

Comment Section:

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed