commint

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • in reply to: Multiple Review Forms? #35344

    commint
    Free User
    Post count: 19
    This reply has been marked as private.
    in reply to: Multiple Review Forms? #35292

    commint
    Free User
    Post count: 19

    @stiofan – like a boss! I was way over-complicating things. Thanks for everybody’s help. I really appreciate it, and I understand how the wpgeodir tabs work so much better now, thank you. Final code:

    
    
    // reviews filter
    	add_action('geodir_before_tab_content' ,'geodir_filter_reviews_content_before');
    
    	function geodir_filter_reviews_content_before($tab_index) {
    		if($tab_index =='reviews')
    		{
    			add_filter( 'comments_array', 'wpq_show_only_normal_comments' );
    		}
    	}
    
    add_action('geodir_after_tab_content' ,'geodir_filter_reviews_content');
    
    	function geodir_filter_reviews_content($tab_index)
    	{
    		if($tab_index =='reviews')
    		{
    			remove_filter( 'comments_array', 'wpq_show_only_normal_comments' ); 
    		}
    	}
    
    // filtering functions
    function wpq_show_only_normal_comments( $comments )
    	{
    	return wpq_filter_comments( array( '', 'pingback', 'trackback' ), $comments );
    	}
    
    function wpq_filter_comments( $comment_type, $comments )
    	{
    	$filtered_comments = array();
    	foreach( (array) $comments as $key => $comment )
    	{
    		if( in_array( $comment->comment_type, $comment_type, true ) )
    		{
    			$filtered_comments[] = $comment;
    		}
    	}
    	return $filtered_comments;
    	}

    Thanks,
    Kieran

    in reply to: Multiple Review Forms? #35202

    commint
    Free User
    Post count: 19
    This reply has been marked as private.
    in reply to: Multiple Review Forms? #35199

    commint
    Free User
    Post count: 19

    Hi Stiofan,

    I need both review tabs and I would like to change the output of the built in wpgeodir reviews list in the Reviews tab if possible. I am already outputting the two separate tabs successfully and my custom Peer Reviews tab works great.

    The problem is that the built in wpgeodir reviews query does not take my custom comment type into account. Therefore both user and peer reviews are displaying on the Reviews tab. I can successfully exclude the peer reviews using my own function, but I would prefer to integrate it with the built in wpgeodir reviews function if possible. The other problem I’ve encountered using my own function is that the star ratings on user reviews do not validate correctly. They always fail when using my new comment form.

    I do have a working solution in place that prints both reviews lists and forms and then uses CSS to hide unneeded elements but that’s a bit sloppy. I’d prefer to filter the built in function.

    Here’s how I’m changing the reviews tab display. You’ll notice I’m not removing any wpgeodir reviews action so I can use the built in comment form that validates correctly:

    
    
    if($tab_index =='reviews')
    		{
    			add_filter( 'comments_array', 'wpq_show_only_normal_comments' );
    			comments_template( '', true );
    			remove_filter( 'comments_array', 'wpq_show_only_normal_comments' ); 
    		}

    And here are the functions that are used to return the “normal comments”:

    
    
    function wpq_show_only_normal_comments( $comments )
    {
    return wpq_filter_comments( array( '', 'pingback', 'trackback' ), $comments );
    }
    
    function wpq_filter_comments( $comment_type, $comments )
    {
    $filtered_comments = array();
    foreach( (array) $comments as $key => $comment )
    {
    if( in_array( $comment->comment_type, $comment_type, true ) )
    {
    $filtered_comments[] = $comment;
    }
    }
    return $filtered_comments;
    }

    So I guess there are two possible solutions – filter the wpgeodir reviews list to exclude peer reviews, or fix the star validation. I must also apologize that my post is not in the correct forum (at least not yet). I originally though I had MultiRatings and Reviews Addon installed but I do not. However, it is likely that my client will want it in the future.

    @urbanfix – Sorry, I can’t share the dev URL publicly at this time but I’ve attached screenshots so you can get an idea.

    in reply to: Multiple Review Forms? #35143

    commint
    Free User
    Post count: 19

    Thanks Paolo. Not a priority. I appreciate your attention.

    Thanks,
    Kieran

    in reply to: Multiple Review Forms? #35067

    commint
    Free User
    Post count: 19

    So the answer to this lies in the following code. This basically sets up a custom comment type called “extra”:
    https://gist.github.com/dbranes/0215762a4cf3db50a6b7

    Instead of using the single.php code outlined above, I needed to add a new tab (peer_reviews) and then filter the tab display to return the correct set of reviews.

    Adding tabs:
    https://wpgeodirectory.com/support/topic/adding-a-new-listing-tab/

    Filtering tabs:

    
    
    // reviews filters
    	add_action('geodir_after_tab_content' ,'geodir_filter_reviews_content');
    	function geodir_filter_reviews_content($tab_index)
    	{
    		if($tab_index =='reviews')
    		{
    			add_filter( 'comments_array', 'wpq_show_only_normal_comments' );
    			comments_template( '', true );
    			remove_filter( 'comments_array', 'wpq_show_only_normal_comments' ); 
    		}
    		
    		if($tab_index =='peer_reviews')
    		{
    			add_action( 'comment_form', 'wpq_hidden_input_field_to_set_extra_comment_content_type' );
    			add_filter( 'comments_array', 'wpq_show_only_extra_comments' );
    			add_filter( 'comment_form_defaults', 'wpq_change_comment_form_defaults' );
    			comments_template( '', true );
    			remove_action( 'comment_form', 'wpq_hidden_input_field_to_set_extra_comment_content_type' );
    			remove_filter( 'comments_array', 'wpq_show_only_extra_comments' );
    			remove_filter( 'comment_form_defaults', 'wpq_change_comment_form_defaults' ); 
    		}
    	}

    After that I ended up with three comment lists – two in the reviews tab, one of which had both peer and normal reviews and one of which had just the normal reviews. The peer reviews tab worked fine. I used CSS to hide the combined review set I didn’t need but I’d prefer not to do it that way because it’s a bit of a hack job.

    Is there a way to alter how the reviews are displayed using my functions.php file? I guess I need to integrate my ‘wpq_show_only_normal_comments’ filter with the wpgeodir reviews output. I understand we’re into customization territory now but I also feel it’s important for me to share snippets and experiences in the forum so that others can benefit.

    Many thanks!

    in reply to: Multiple Review Forms? #34191

    commint
    Free User
    Post count: 19

    OK, thanks Paolo. It will be a while before I tackle this but I will let you know how things go. My research is pointing me this way for now:
    http://wpquestions.com/question/showChrono/id/9749

    in reply to: Breadcrumb shows same location for different cities #33582

    commint
    Free User
    Post count: 19

    I figured out how to override the location setter that activates when you click on a city link in the breadcrumb navigation. This is obviously not what 99% of people will want to do, but in my case I never want the user to choose a location, even by accident. The user location information is held in a session, so you just need to unset the relevant variables. When I clicked on a city in the breadcrumb, the session was being created and interfering with my own expected experience.

    
    
    // override multilocation setter
    unset( $_SESSION['gd_multi_location'] );
    unset( $_SESSION['gd_country'] );
    unset( $_SESSION['gd_region'] );
    unset( $_SESSION['gd_city'] );
    in reply to: Breadcrumb shows same location for different cities #33546

    commint
    Free User
    Post count: 19

    I’ve been able to recreate the “problem” which I now think is a feature.

    1. Navigate to a listing on the site
    2. Click on the city in the breadcrumb nav
    3. This city gets stuck in the permalinks and then filters the categories by that town

    I tried it on your demo site and I saw that the city (Philadelphia) became the user city selection. Therefore I am presuming that by clicking the city link in my breadcrumbs I am setting my base city without realizing it.

    I am using one default region and country and I am using city slugs in my permalinks. I am not showing the location switcher in menu and I do not request location info when the user first visits the site.

    I understand why this might be the default behaviour, but is it possible to override it, or to drop all reference to cities in the category queries? I can bypass the city pages using redirects.

    in reply to: Breadcrumb shows same location for different cities #33536

    commint
    Free User
    Post count: 19

    Hi Guust,

    Thanks for the info. I continue to have problems when I use Firefox, but switching to another browser or computer fixes the problem. My issue is too localized. It is probably a cache problem. I do now have the permalink structure that I prefer. Thank you.

    in reply to: Breadcrumb shows same location for different cities #33480

    commint
    Free User
    Post count: 19

    Hi Guust,

    Thanks for the swift response. That helped the breadcrumb situation but now my tags and category archives are empty. I’ve tried regenerating permalinks, clearing cache and resyncing tags/categories and virtual pages from GD Tools.

    Can I use location city slugs in my permalinks if I use a default region and default country? My directory will only cover one region and having the location in the permalink is a big plus for SEO.

    When I switch that option back on the persistent city reappears in my breadcrumbs. Switching this option off removes locations from the breadcrumb/permalinks anyway so I’m not sure it actually addresses the problem. By the way, I have place tags that have the same name as some of my cities.

    in reply to: Breadcrumb shows same location for different cities #33467

    commint
    Free User
    Post count: 19
    This reply has been marked as private.
    in reply to: Future support for recurring payments? #27174

    commint
    Free User
    Post count: 19

    Thanks for the prompt reply as always Stiofan.

    in reply to: How do Neighbourhoods work with Google API? #27136

    commint
    Free User
    Post count: 19

    OK great, thank you Guust. This can be marked resolved. In my case I will need to set up separate cities.

    in reply to: Order Listings by Pricing Package #26781

    commint
    Free User
    Post count: 19

    Thanks for pointing me in the right direction Stiofan. This works perfectly. Just wondering, is there a repository available of the most useful/popular hooks?

Viewing 15 posts - 1 through 15 (of 16 total)