blank spaces in url show %20 not –

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 Ernest Marcinko 4 years, 1 month ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #25756
    JustinJon3s
    JustinJon3s
    Participant

    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%20doe

    The 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

    #25757
    JustinJon3s
    JustinJon3s
    Participant

    I 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;
    }

    #25770
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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 :)


    #25771
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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 :)


    #25904
    JustinJon3s
    JustinJon3s
    Participant
    You cannot access this content.
    #25905
    JustinJon3s
    JustinJon3s
    Participant
    You cannot access this content.
    #25928
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Well, 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 :)


Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.