Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › {USER_LOGIN} parameter
- This topic has 6 replies, 2 voices, and was last updated 7 years, 1 month ago by
Ernest Marcinko.
-
AuthorPosts
-
April 24, 2019 at 9:32 am #22281
sabbella
ParticipantHello,
I need a custom URL scheme in “General Options -> User search” , with {USER_LOGIN} at the end of the url.
The problem is that I need to get the users without spaces, without @, with – instead of . and lowercase.
I have this code:
foreach ( $user ) {
$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 );How can include it to the {USER_LOGIN} parameter?
Thank you,
April 24, 2019 at 10:09 am #22285Ernest Marcinko
KeymasterHi,
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; }April 24, 2019 at 10:41 am #22289sabbella
ParticipantThank you Ernest, it works super-fine 🙂
I have other issue, I only get a maximum of 20 search results, always, although it should be more results displayed. Is there any option where this is set?
Thank you,
April 24, 2019 at 10:48 am #22290sabbella
ParticipantYou cannot access this content.
April 24, 2019 at 12:21 pm #22291Ernest Marcinko
KeymasterYou cannot access this content.
April 24, 2019 at 12:51 pm #22293sabbella
ParticipantThank you 🙂
April 24, 2019 at 1:01 pm #22297Ernest Marcinko
KeymasterYou cannot access this content.
-
AuthorPosts
- You must be logged in to reply to this topic.