This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: {USER_LOGIN} parameter

#22285
Ernest MarcinkoErnest Marcinko
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;
}