ASP only searching users

This topic contains 2 replies, has 2 voices, and was last updated by angusryall26 angusryall26 2 years, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #30427
    angusryall26
    angusryall26
    Participant

    Hi, I am using ASP on a membership site, which uses Ultimate Member to handle the user profiles etc. I had ASP configured nicely to search all pages, posts, and user profiles, however, since updating Ultimate Member a couple of weeks ago ASP is no longer working correctly. It still searches all the users correctly, but doesn’t search any other pages or posts. The configuration is exactly the same.

    I do have a couple of functions in functions.php relating to how ASP deals with users, see below, but I can’t see how these would affect any non-user results. The first one checks for a description field and excludes users from the search if it is not there. The second one actually I can’t even remember what it does.

    To test, you can use ‘Spain’ – this is in the title of one post, it should return ‘Shanti yoga retreat in Spain with Jill Davies-Prosser’, and ‘Ryall’ – that is in the user details of quite a few users.

    /*ajax search pro exclude new registrants using description field*/
    add_filter(‘asp_query_args’, ‘asp_add_my_meta_filter’, 10, 1);
    function asp_add_my_meta_filter( $args ) {
    $description = get_user_meta( um_user( ‘ID’ ), ‘description’, true );
    $args[‘post_meta_filter’][] = array(
    ‘key’ => $description,
    ‘value’ => ”,
    ‘operator’ => ‘=’,
    ‘allow_missing’ => false
    );
    return $args;
    }

    //Ajax search pro add categories to output
    add_filter( ‘asp_results’, ‘asp_add_taxonomy_titles’, 10, 1 );
    function asp_add_taxonomy_titles( $results ) {
    // Change these variables according to your needs
    $taxonomy = ‘category’; // ‘category’, ‘post_tag’, ‘product_tag’, ‘product_cat’ etc..
    $field = ‘title’; // the field to place the items: ‘title’ or ‘content’
    $location = ‘after’; // ..terms location: ‘before’ or ‘after’ the filed
    $delimiter = ‘, ‘; // delimiter between each term
    $before_output = ‘ – ‘; // text/HTML before terms output
    $after_output = ”; // text/HTML after terms output

    // ————- Do not change anything below ————–
    $taxonomies = is_array($taxonomy) ? $taxonomy : explode(‘,’, str_replace(‘ ‘, ”, $taxonomy));
    foreach ($results as $k=>&$r) {
    foreach ($taxonomies as $taxonomy) {
    if ( $r->content_type == ‘pagepost’ ) {
    $terms = wp_get_post_terms( $r->id, trim( $taxonomy ), array( “fields” => “names” ) );
    if ( !is_wp_error($terms) && count($terms) > 0 ) {
    $out = implode($delimiter, $terms);
    if ( !empty($out) ) {
    $out = $before_output . $out . $after_output;
    if ( $field == ‘title’ ) {
    if ( $location == ‘after’ )
    $r->title .= ” “.$out;
    else
    $r->title = $out . ‘ ‘ . $r->title;
    } else {
    if ( $location == ‘after’ )
    $r->content .= ” “.$out;
    else
    $r->content = $out . ‘ ‘ . $r->content;
    }
    }
    }

    }
    }
    }
    return $results;
    }

    #30447
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    If nothing was changed, then I strongly suspect the first piece of code. There might have been a change in UM, so that the filter may no longer work as expected. You should test by removing the first piece of code, or simply commenting this line:

    //add_filter(‘asp_query_args’, ‘asp_add_my_meta_filter’, 10, 1);

    Then try a couple of phrases.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #30457
    angusryall26
    angusryall26
    Participant

    Great! That fixed it, and the functionality that code was bringing – hide user from search if they are ‘pending’ – still works!

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

The topic ‘ASP only searching users’ is closed to new replies.