Newbie WordPress developer here.
I need to map a WordPress URL like this www.example.com/user/Username
to a search result based on that Username
I already have the page that makes the search with the url www.example.com/search-results/?name=Username
In the functions.php
I have
add_action( 'init', 'add_username_rules' );
function add_username_rules()
{
global $wp_rewrite;
add_rewrite_rule(
"user/([^/]*)",
"search-result/?name=$matches[0]",
"top"
);
$wp_rewrite->flush_rules();
}
But this is not working and the rule is going to non_wp_rules
.