Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › {USER_LOGIN} parameter
This topic contains 6 replies, has 2 voices, and was last updated by Ernest Marcinko 3 years, 11 months ago.
- AuthorPosts
- April 24, 2019 at 9:32 am #22281
Hello,
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 #22285Hi,
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:
Best,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; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
April 24, 2019 at 10:41 am #22289Thank 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 #22290You cannot access this content.April 24, 2019 at 12:21 pm #22291You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
April 24, 2019 at 12:51 pm #22293Thank you 🙂
April 24, 2019 at 1:01 pm #22297You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.