This topic has 29 replies, 5 voices, and was last updated 10 years by Abe.

  • Author
  • #30659
     justvinnie
    Participant

    The live search feature works great for posts and pages but I run a professions site and would like live search to search member profiles. Is there an easy way to do this?

    I appreciate your help. Thanks.

    #30685
     sharmstr
    Moderator

    +1 This is needed. While I like that you can target content searches while within the specific component, making users navigate there is not ideal.

    Its been suggested here https://archived.seventhqueen.com/forums/topic/kleo-features-requests/page/2/#post-20300 and I believe somewhere else that I cant find at the moment. I also think I remember the kleo team saying that they were working on it.

    Hmmm. Maybe I’ll try hacking while I finish my coffee.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #30690
     sharmstr
    Moderator

    Okay, I threw this together. Put it in your functions.php file. I’ve done some initial testing and seems to work. Let me know how it works out for you.

    COPY CODE
    
    
    /*add member results to live search */
    function kleo_ajax_search()
    {
    	//if "s" input is missing exit
    	if(empty($_REQUEST['s'])) die();
    
    	$output = "";
    	$defaults = array('numberposts' => 4, 'post_type' => 'any', 'post_status' => 'publish', 'post_password' => '', 'suppress_filters' => false);
    	$defaults =  apply_filters( 'kleo_ajax_query_args', $defaults);
    
    	$query = array_merge($defaults, $_REQUEST);
    	$query = http_build_query($query);
    	$posts = get_posts( $query );
    	
    	
    	$members = bp_core_get_users(array('search_terms' => $_REQUEST['s'], 'per_page' => 4, 'populate_extras' => false));
    
    		//if there are no posts
    	if(empty($posts)  && $members['total'] == 0)
    	{
    		$output  = "<div class='kleo_ajax_entry ajax_not_found'>";
    		$output .= "<div class='ajax_search_content'>";
    		$output .= "<i class='icon icon-exclamation-sign'></i> ";
    		$output .= __("Sorry, no pages matched your criteria.", 'kleo_framework');
    		$output .= "<br>";
    		$output .= __("Please try searching by different terms.", 'kleo_framework');
    		$output .= "</div>";
    		$output .= "</div>";
    		echo $output;
    		die();
    	}
    	
    	//if there are members
    	if ($members['total'] != 0) {
    		$output .= "<h4>Members</h4>";
    		$output .= "<div>";
    		foreach ( (array) $members['users'] as $member ) {	
    			$image = '<img /> $member-> ID, 'width' => 25, 'height' => 25, 'html' => false)) . '" class="kleo-rounded" alt="">';
    			$link = apply_filters('kleo_custom_url', get_permalink($member->ID));
    			$classes = "format-".$format;
    			$output .= "<div class ='kleo_ajax_entry $classes'>";
    			$output .= "<div class='ajax_search_image'>$image</div>";
    			$output .= "<div class='ajax_search_content'>";
    			$output .= "<a>ID)."' class='search_title'>";
    			$output .= $member->display_name;
    			$output .= "</a>";
    			$output .= "</div>";
    			$output .= "</div>";
    		}
    		$output .= "<a>".__('View member results','kleo_framework')."</a>";
    		$output .= "</div>";
    	}
    	
    	//if there are posts
    	$post_types = array();
    	$post_type_obj = array();
    	foreach($posts as $post)
    	{
    		$post_types[$post->post_type][] = $post;
    		if(empty($post_type_obj[$post->post_type]))
    		{
    			$post_type_obj[$post->post_type] = get_post_type_object($post->post_type);
    		}
    	}
    
    	foreach($post_types as $ptype => $post_type)
    	{
    		if(isset($post_type_obj[$ptype]->labels->name))
    		{
    			$output .= "<h4>".$post_type_obj[$ptype]->labels->name."</h4>";
    		}
    		else
    		{
    			$output .= "<hr>";
    		}
    		foreach($post_type as $post)
    		{
    			$format = get_post_format($post->ID);
    			if (get_the_post_thumbnail( $post->ID, 'thumbnail' ))
    			{
    				$image = get_the_post_thumbnail( $post->ID, 'thumbnail' );
    			}
    			else
    			{
    				if ($format == 'video') {
    					$image = "<i class='icon icon-video'></i>";
    				}
    				elseif ($format == 'image' || $format == 'gallery') {
    					$image = "<i class='icon icon-picture'></i>";
    				}
    				else {
    					$image = "<i class='icon icon-link'></i>";
    				}
    			}
    
    			$excerpt = "";
    
    			if(!empty($post->post_content))
    			{
    				$excerpt =  "<br>".char_trim(trim(strip_tags(strip_shortcodes($post->post_content))),40,"...");
    			}
    			$link = apply_filters('kleo_custom_url', get_permalink($post->ID));
    			$classes = "format-".$format;
    			$output .= "<div class ='kleo_ajax_entry $classes'>";
    			$output .= "<div class='ajax_search_image'>$image</div>";
    			$output .= "<div class='ajax_search_content'>";
    			$output .= "<a href='$link'>";
    			$output .= get_the_title($post->ID);
    			$output .= "</a>";
    			$output .= "<span class='search_excerpt'>";
    			$output .= $excerpt;
    			$output .= "</span>";
    			$output .= "</div>";
    			$output .= "</div>";
    		}
    	}
    
    	$output .= "<a>".__('View all results','kleo_framework')."</a>";
    
    	echo $output;
    	die();
    }
    
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    Attachments:
    You must be logged in to view attached files.
    #30695
     justvinnie
    Participant

    What kind of coffee did you drink? Wow…Great reply!

    Unfortunately I can’t work on this for a couple of hours but I did want to say thank you for your hard work.

    I will reply soon. Thanks!

    #30696
     sharmstr
    Moderator

    LOL. Its not perfect, but should get you by until there’s official support in Kleo.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #30700
     justvinnie
    Participant

    Howdy.

    I added the code to my child functions page and receive this error:

    Parse error: syntax error, unexpected T_STRING

    on this line:

    $image = '<img /> $member-> ID, 'width' => 25, 'height' => 25, 'html' => false)) . '" class="kleo-rounded" alt="">';

    #30701
     sharmstr
    Moderator

    Please re-paste that but put pre tags around it so I can see the whole thing.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #30703
     justvinnie
    Participant

    Sorry. Let’s try this again:

    $image = '<img /> $member-> ID, 'width' => 25, 'height' => 25, 'html' => false) . '" class="kleo-rounded" alt="">';

    #30704
     justvinnie
    Participant

    Sorry… my apologies. I did it again. I was also messing with the code and I shared the wrong one.

    #30705
     sharmstr
    Moderator

    should be this…

    COPY CODE
    
    
    $image = '<img /> $member-> ID, 'width' => 25, 'height' => 25, 'html' => false)) . '" class="kleo-rounded" alt="">';
    
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #30706
     sharmstr
    Moderator

    it keeps doing it. let me attach

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    Attachments:
    You must be logged in to view attached files.
    #30708
     justvinnie
    Participant

    Error

    #30709
     justvinnie
    Participant

    I copied and pasted the attachment code.

    It works! Quite beautifully as a matter of fact. Perfect!

    Thank you for helping out — You’re the best!

    #30713
     sharmstr
    Moderator

    Sweet. I need to remember to just attach a file next time. Whoop!

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #30715
     justvinnie
    Participant

    Thank you again @sharmstr for your excellent work. I have one last question…

    Is there a way to disable ‘enter’ on the live search bar?

    When I type in the search bar, I naturally want to press ‘enter’ after typing. The query has a small delay and the results don’t drop down fast enough to realize that’s how it works.

    Pressing enter takes me to the results page showing pages and posts but doesn’t include the member results. If it’s possible to show members then great but I think that gets tricky.

    Disabling the enter and forcing the user to choose from the drop down list seems like the best way to go.

    Any ideas?

    #30716
     sharmstr
    Moderator

    jQuery is your friend on this one and a very common request on the interwebs. Take your pick https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=disable+enter+submit+wordpress

    If you cant sort it, let me know and I’ll do it tomorrow morning over coffee 🙂

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #30774
     giorgos
    Participant

    Perfect, Thanks! Only issue I have is the link “view member results” gives a 404 as it is appending /members?s=….
    to the current url.
    So if you search from a visited url, lets say sitename/groups/iphone-5/ it will give the link for “view members results” as “sitename/groups/iphone-5/members/?s=….”

    This is only the case on buddypress urls. When you search while visiting a blog url, or any other custom type post then it redirects fine to sitename/members?s=….

    Is this behavior observed on others too?

    #30786
     sharmstr
    Moderator

    @giorgos

    change the following on the “view member results” line

    COPY CODE
    bp_get_members_slug()

    to

    COPY CODE
    
    site_url()."/".bp_get_members_slug()
    

    I’ll upload a new file when I’m done tweaking a few other things.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #30793
     giorgos
    Participant

    Solved. Thanks!!

    #30798
     sharmstr
    Moderator

    Here’s version 2 of the code. I’ve added an excerpt of the members latest activity and at the bottom of the attached file, there’s instructions and code on how to disable the enter button from submitting the search form. Let me know if there are any issues.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    Attachments:
    You must be logged in to view attached files.
    #30815
     giorgos
    Participant

    New version gives me a warning

    Warning: Illegal string offset ‘content’ in /wp-content/themes/kleo-child/functions.php on line 164

    line 164 =
    $latest_activity = "<br>".char_trim( trim( strip_tags( bp_create_excerpt( $update['content'], 50,"..." ) ) ) );

    #30828
     sharmstr
    Moderator

    I need a link to your site and the exact string you typed into the search box

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #30830
     giorgos
    Participant

    http://www.applesocial.net
    I typed “test”

    #30845
     sharmstr
    Moderator

    Got it. The problem was that those members didnt have any updates. They had activity, but it was stuff like ‘friends’ and ‘joined group’. I have a custom function on my site that doesnt add any of those activities to the db, so it was hard to test for that. Anyhow, can you add the new code that’s attached and see if it fixes it?

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    Attachments:
    You must be logged in to view attached files.
    #30847
     giorgos
    Participant

    Just perfect. v3 works fine. Thanks!

    #31363
     Abe
    Keymaster

    Hello,
    We will include this functionality with small styling tweaks in our next update.
    Big big thanks to @sharmstr

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #31870
     Franklin Symphony
    Participant

    Hi. I just bought your theme and set it up. I decided to test the registration and add some users manually, because I really like the Members Carousel feature. The feature show’s members and work’s perfect with the BuddyPress Default Data plugin. But it does not work at all when I create a new user manually when going through the complete registration process. Also, during signup, I input a valid email address. But there is no email that’s been sent out. When I check the seven different types of emails, none of them got the email from registration. Weird right? So what’s the difference between the plugins user’s showing up in the Members Carousel feature, versus real people who will be signing up and not showing up in the Members carousel feature and not even on the members page for that matter. I know this should be the easiest thing in the world and shouldn’t even be a topic, which is why it’s not even an issue in the forums. I have compared users from the BuddyPress Default Data plugin, versus the ones I create manually and I can see not a single difference of the ones showing up in the members page and members Carousel, while the real users who register don’t show up at all in it……It should be so easy right?….so I MUST be missing something…I mean there must be something I don’t know about. Do you have any idea what the mystery behind all that is?

    #31874
     sharmstr
    Moderator

    Hey Franklin, Welcome.

    Your questions are probably best answered over on the Buddypress forum since those are all functions of Buddypress. But, are the users listed under wp admin -> Users -> Manage signups? If so, they’re not active yet. When you create an account on the frontend (like a normal user would) they wont show up until they activate their account or until you activate them in Manage Signups. For a user to activate their own account, they need to click on the link in the email (which aren’t being sent).

    Now, for ones that you’ve created in the backend. The Members directory defaults to only showing “last active”. If you’ve only created the accounts, but didnt log into them, they have no activity and therefore will not show up. If you change the order by dropdown to alphabetical, you’ll see them. I’ve never imported the Buddypress demo content, but those demo accounts probably have activity and therefore show up.

    Same goes for the member carousel. It defaults to Active. Change it to alphabetical and see if they show up.

    I suggesting taking some time to read the Buddypress documentation.

    As far as your email issues go, that’s a either a wordpress or buddypress issue. More than likely something isn’t configured correctly on your server. Do you get other emails such as Buddypress notifications? Do a google search. I’m sure there’s a wealth of info out there that will help.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #31905
     Franklin Symphony
    Participant

    Thank you very very much. That worked. I did however try all of the things you had told me beforehand. Yet the one thing I was missing was logging the manually created user’s in. And that did the trick. AS for the emails not working, I think your right. I have to contact my web hosting company for that. Thank you very much for your help. I have bought and seen many great themes but I think I can truthfully say that this one tops them all. there’s one theme called “X”, an all multi purpose, “thing of the future” type of theme. I played with it for awhile and as it does have features that are not commonly put into most themes, however, I’m so sorry to say that, that thing has absolutely nothing over this one, Kleo. None of them do. X needs to go back to the drawing board on that to be able to compete with this one. Keep’em under your feet, and thank you very much. Until I contact you again, take care.

    #31934
     Abe
    Keymaster

    Thank you very much Franklin, we are very happy to hear that 🙂


    @sharmstr
    you are a star 🙂

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

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

The forum ‘KLEO’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?