BP Profile Search › Field to search users for a published post type
-
AuthorPost
-
Patrique Uiliam
GuestHi 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. ?andrea
Plugin AuthorHi Patrique,
Could you please send me a WP admin access to your test site? You can use my Contact page to share it privately.
Patrique Uiliam
GuestI sent admin access, to your contact page, Andrea!
andrea
Plugin AuthorThank you, Patrique.
I’ve been able to log into your test site, and I’ll let you know soon what I find.
andrea
Plugin AuthorLuckily 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!
Patrique Uiliam
GuestHi Andrea! Thank you very much! The problem was solved. You helped me!!!!!! I am very happy! 🙂 🙂 🙂
andrea
Plugin AuthorGreat! You are very welcome.
Patrique Uiliam
GuestHi 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?
andrea
Plugin AuthorHi Patrique,
Unfortunately that’s not possible, “Any Profile Field” is restricted to actual profile fields. Sorry!
-
AuthorPost