Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › blank spaces in url show %20 not –
This topic contains 6 replies, has 2 voices, and was last updated by Ernest Marcinko 4 years, 6 months ago.
- AuthorPosts
- February 10, 2020 at 8:54 pm #25756
Ajax Search Pro used in peeps as per peepso’s recommendation.
My problem is that when I search for a peepso profile and the result has a blank.
For instance:
search for “John Doe” the result shows a profile (avatar does not show up only default please help with this too)
the link in peepso is :
john-doe
ajax link to the profile is:
john%20doeThe search works fine if there is no spaces in the name. It is using the custom scheme “profile/{USER_LOGIN}” and works well(except for the avatar issue) when the username has no spaces for instance profile/johndoe
We have not publicly launched yet.
Please help
February 10, 2020 at 9:39 pm #25757I found a work around. adding a function to not allow for usernames with spaces.
// Force no username spaces
function custom_validate_username($valid, $username ) {
if (preg_match(“/\\s/”, $username)) {
// there are spaces
return $valid=false;
}return $valid;
}February 11, 2020 at 4:00 pm #25770Hi,
Okay, I will keep this topic open in case.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 11, 2020 at 4:00 pm #25771Hi,
Okay, I will keep this topic open in case.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 20, 2020 at 7:26 pm #25904You cannot access this content.February 20, 2020 at 7:48 pm #25905You cannot access this content.February 21, 2020 at 4:15 pm #25928Well, there might be a way to do that via custom code, but I am not sure if it would work.
First, change the custom URL structure, so that the {user_login} variable is not there at the end, so in your case I guess it’s:
profile/
Then, 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!
add_filter( 'asp_results', 'asp_custom_ur_url', 10, 1 ); function asp_custom_ur_url($results) { foreach ( $results as $k => &$r ) { if ( $r->content_type == 'user' ) { $u = get_user_by('ID', $r->id); $r->link .= preg_replace("/[^A-Za-z0-9 ]/", '-', $u->user_login); } } return $results; }
This should append the user login to the end of each user result URL, replacing any non-alphanumeric character with a dash.
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.