[Advanced] How to modify Ratings & Reviews entry comment titles

When using GravityView Ratings & Reviews, you may want to customize how entry comment titles appear using data from the Gravity Forms entry submission. This guide shows you how to use the gv_ratings_reviews_post_bridge_title filter to achieve this.

ℹ️ The gv_ratings_reviews_post_bridge_title filter only affects new entries. Existing entries will keep their current titles unless regenerated

Overview

By default, entry comment titles display as "GF entry ID {ID}, GF form ID {ID}". You can customize this to include meaningful data from your form submissions, such as the submitter's name, product name, or any other field value.


Basic example: Show the form name

add_filter( 'gv_ratings_reviews_post_bridge_title', 'gk_use_custom_comment_title', 10, 2 );


/**
 * Basic customization of the Comment title on entries.
 *
 * @since 1.0.0
 *
 * @param string $title The default title for the comment.
 * @param array  $entry The Gravity Forms entry array.
 *
 * @return string The modified title in the format of '{Field:3} on {form_title}'
 */
function gk_use_custom_comment_title( $title, $entry ) {

    // UPDATE THIS!! to the field ID you want to use.
    $field_id = '3';

    $form = GFAPI::get_form( $entry['form_id'] );

    if ( ! $form ) {
        return $title; // Something's not right! Use original.
    }

    $value = rgar( $entry, $field_id, '(Untitled)' );
    $form_name = $form['title'];

    return sprintf( '%s on %s', sanitize_text_field( $value ), sanitize_text_field( $form_name ) );
}

Example 1: Using a company name

If your form has a Company Name field with field ID 1, use it in the title with this code:

add_filter( 'gv_ratings_reviews_post_bridge_title', 'gk_use_custom_comment_title', 10, 2 );


/**
 * Use the company name in the comment title.
 *
 * @since 1.0.0
 *
 * @param string $title The default title for the comment.
 * @param array  $entry The Gravity Forms entry array.
 * @return string The modified title containing the submitter's name.
 */
function gk_use_custom_comment_title( $title, $entry ) {

	// UPDATE THIS!! to the field ID you want to use.
	$field_id = '3';

	$form = GFAPI::get_form( $entry['form_id'] );

	if ( ! $form ) {
		return $title;
	}

	$value = rgar( $entry, $field_id, '(Untitled)' );
	$form_name = $form['title'];

	return sprintf( '%s on %s', sanitize_text_field( $value ), sanitize_text_field( $form_name ) );
}

Example 2: Product Review Title

For product reviews, include both the product name and reviewer:

add_filter( 'gv_ratings_reviews_post_bridge_title', 'gk_product_review_title', 10, 2 );


/**
 * Create a product review title with product name and reviewer.
 *
 * @since 1.0.0
 *
 * @param string $title The default title for the comment.
 * @param array  $entry The Gravity Forms entry array.
 * @return string The modified title with product and reviewer information.
 */
function gk_product_review_title( $title, $entry ) {
    // Field 2 = Product Name, Field 3 = Reviewer Name
    $product = rgar( $entry, '2' );
    $reviewer_first = rgar( $entry, '3.3', '' );
    $reviewer_last = rgar( $entry, '3.6', '' );
    $reviewer = trim( $reviewer_first . ' ' . $reviewer_last );
    
    if ( ! empty( $product ) && ! empty( $reviewer ) ) {
        $title = sprintf( 
            '%s - Review by %s', 
            sanitize_text_field( $product ), 
            sanitize_text_field( $reviewer ) 
        );
    }
    
    return $title;
}

Example 3: Using Gravity Forms Merge Tags

You can also use Gravity Forms merge tags for more complex formatting:

add_filter( 'gv_ratings_reviews_post_bridge_title', 'gk_merge_tag_title', 10, 2 );
/**
 * Use Gravity Forms merge tags to format the comment title.
 *
 * @since 1.0.0
 *
 * @param string $title The default title for the comment.
 * @param array  $entry The Gravity Forms entry array.
 * @return string The modified title with processed merge tags.
 */
function gk_merge_tag_title( $title, $entry ) {
    // Get the form object
    $form = GFAPI::get_form( $entry['form_id'] );
    
    if ( ! $form ) {
        return $title;
    }
    
    // Define your custom title format with merge tags
    $title_format = 'Review: {Name:1} - {Product:2} ({Date:3})';
    
    // Process the merge tags
    $title = GFCommon::replace_variables( $title_format, $form, $entry );
    
    return sanitize_text_field( $title );
}

Example 4: Conditional Title Based on Form

Different titles for different forms:

add_filter( 'gv_ratings_reviews_post_bridge_title', 'gk_form_specific_title', 10, 2 );

/**
 * Apply different title formats based on the form ID.
 *
 * @since 1.0.0
 *
 * @param string $title The default title for the comment.
 * @param array  $entry The Gravity Forms entry array.
 * @return string The modified title based on form-specific logic.
 */
function gk_form_specific_title( $title, $entry ) {
    switch ( (int) $entry['form_id'] ) {
        case 1: // Product Review Form
            $product = rgar( $entry, '2' );
            if ( ! empty( $product ) ) {
                $title = sprintf( 'Product Review: %s', sanitize_text_field( $product ) );
            }
            break;
            
        case 2: // Service Feedback Form
            $service = rgar( $entry, '5' );
            $date = rgar( $entry, 'date_created' );
            if ( ! empty( $service ) ) {
                $title = sprintf( 
                    'Service Feedback: %s (%s)', 
                    sanitize_text_field( $service ), 
                    date( 'M j, Y', strtotime( $date ) ) 
                );
            }
            break;
            
        default:
            // Keep the default title for other forms
            break;
    }
    
    return $title;
}
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us