Field to search users for a published post type

Home Forums BP Profile Search Forum Field to search users for a published post type

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #11295 Reply
    Patrique Uiliam
    Guest

    Hi Andrea!

    Topic referring to the code (open on the wordpress forum and continuing here):

    add_filter ('bps_add_fields', 'bps_posts_setup', 99);
    function bps_posts_setup ($fields)
    {
    	$columns = array
    	(
    //		'ID'				=> 'integer',
    //		'post_author'			=> 'integer',
    		'post_date'			=> 'date',
    //		'post_date_gmt'			=> 'date',
    		'post_content'			=> 'text',
    		'post_title'			=> 'text',
    //		'post_excerpt'			=> 'text',
    		'post_status'			=> 'text',
    //		'comment_status'		=> 'text',
    //		'ping_status'			=> 'text',
    //		'post_password'			=> 'text',
    //		'post_name'			=> 'text',
    //		'to_ping'			=> 'text',
    //		'pinged'			=> 'text',
    //		'post_modified'			=> 'date',
    //		'post_modified_gmt'		=> 'date',
    //		'post_content_filtered'		=> 'text',
    //		'post_parent'			=> 'integer',
    //		'guid'				=> 'text',
    //		'menu_order'			=> 'integer',
    		'post_type'			=> 'text',
    //		'post_mime_type'		=> 'text',
    		'comment_count'			=> 'integer',
    	);
    
    	$columns = apply_filters ('bps_posts_columns', $columns);
    	foreach ($columns as $column => $format)
    	{
    		$f = new stdClass;
    		$f->group = __('Posts data', 'bp-profile-search');
    		$f->code = $column;
    		$f->name = $column;
    		$f->description = '';
    
    		$f->format = $format;
    		$f->options = array ();
    		$f->search = 'bps_posts_search';
    
    		$fields[] = $f;
    	}
    
    	return $fields;
    }
    
    function bps_posts_search ($f)
    {
    	global $wpdb;
    
    	$column = $f->code;
    	$filter = $f->format. '_'.  ($f->filter == ''? 'is': $f->filter);
    	$value = $f->value;
    
    	$sql['select'] = "SELECT DISTINCT post_author FROM {$wpdb->posts}";
    	$sql['where'] = bps_where ($column, $filter, $value);
    
    	$sql = apply_filters ('bps_field_sql', $sql, $f);
    	$query = $sql['select']. ' WHERE '. implode (' AND ', $sql['where']);
    
    	$results = $wpdb->get_col ($query);
    	return $results;
    }

    I took the tests and the results still don’t show up.

    1) I installed a new WordPress for testing.
    2) I created the bp-custom.php file and placed the function.
    3) I created two publications and two users.
    4) I created a simple form to search the post title and author name.
    5) When I search for the post name, the results don’t appear.
    6) Here is the test URL: http://newrel.com/testtest/members/
    7) Here is the user… login: test password: pass
    8) I don’t know how to resolve this issue. 🙁

    #11297 Reply
    andrea
    Keymaster

    Hi Patrique,

    Could you please send me a WP admin access to your test site? You can use my Contact page to share it privately.

    #11298 Reply
    Patrique Uiliam
    Guest

    I sent admin access, to your contact page, Andrea!

    #11301 Reply
    andrea
    Keymaster

    Thank you, Patrique.

    I’ve been able to log into your test site, and I’ll let you know soon what I find.

    #11302 Reply
    andrea
    Keymaster

    Luckily it was a simple mistake in my bp-custom.php code.

    It’s fixed now in your test site, so you can copy it wherever you need it.

    Please let me know if you find more problems!

    #11303 Reply
    Patrique Uiliam
    Guest

    Hi Andrea! Thank you very much! The problem was solved. You helped me!!!!!! I am very happy! 🙂 🙂 🙂

    #11305 Reply
    andrea
    Keymaster

    Great! You are very welcome.

    #11316 Reply
    Patrique Uiliam
    Guest

    Hi Andrea!

    It’s working great. I’m already using it and it solved my problem! However, it is not possible to search using the “Any Profile Field” option. Is there such a possibility?

    #11321 Reply
    andrea
    Keymaster

    Hi Patrique,

    Unfortunately that’s not possible, “Any Profile Field” is restricted to actual profile fields. Sorry!

Viewing 9 posts - 1 through 9 (of 9 total)
Reply To: Field to search users for a published post type
Your information: