Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › {USER_LOGIN} parameter › Reply To: {USER_LOGIN} parameter
April 24, 2019 at 10:09 am
#22285
Keymaster
Hi,
Well, the only way to do that is by completely changing the result URL, as that parameter is replaced without any filtering. I have made a custom code to start you off with. Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case! I did not test this code, so please be careful. Change the $r->link line according to your needs:
add_filter( 'asp_results', 'asp_custom_user_url', 10, 1 );
function asp_custom_user_url( $results ) {
foreach ($results as $k => &$r ) {
if ( $r->content_type == 'user' ) {
$user = get_user_by('ID', $r->id);
// Your custom code
$usuario = $user->user_login;
$usuario = str_replace(".","-", $usuario);
$usuario = str_replace(" ","-", $usuario);
$usuario = str_replace(" ","-", $usuario);
$usuario = str_replace("@","", $usuario);
$usuario = strtolower($usuario);
//echo esc_html( $usuario );
$r->link = home_url("/") . $usuario; // Build your custom URL structure here
}
}
return $results;
}