Customizable approval link text

One thing I’m missing with GravityView (that Gravity Flow has) is the ability to set the approval link text. Sometimes “confirm” or “authorize” fits better than “approve”. This could be accomplished in three different ways.

  1. Create a new merge tag for just the URL for total flexibility.
  2. Add the link text as a parameter to the existing merge tag ({gvapproveentry}).
  3. Add a filter for the link text. Remember to pass the form object or the form ID as an argument so that the link can be customized for each form.

I’ve submitted this as a feature request.

The suggestion is public. Please consider voting for it if you want this feature to be added.

Hi @user5ab22cd517e418.1, thanks for the suggestion!

It’s not easy to pass the form around, but the entry ID is available using $_GET['entry_id']. You could then get the form from the entry ID.

Would adding a filter here work for you?

Hi @katzwebservices.

If we can get the entry ID there and modify the text as shown in emails, it would work. My solution was to modify the replace_merge_tag function in the GravityView_Entry_Approval_Merge_Tags class.

Here’s my modification.

$link_url = $this->get_link_url( $token, $expiration_seconds, $privacy );

$anchor_text = GravityView_Entry_Approval_Status::get_action( $action . 'd' );

/* --- START OPAL EDIT  --- */

/**
 * Modify the anchor text for the entry approval link.
 *
 * @param string $anchor_text The anchor text to filter. 
 * @param int $form_id The Form ID.
 * @param string $action The link action (e.g., 'approve').
 * @return string The filtered anchor text. 
 */

$anchor_text = apply_filters( 'gk/gravityview/approve-link/anchor-text', $anchor_text, $form['id'], $action );

/* --- END OPAL EDIT --- */

$link = sprintf( '<a href="%s">%s</a>', esc_url_raw( $link_url ), esc_html( $anchor_text ) );

$text = str_replace( $full_tag, $link, $text );

I added the action (string) as a third argument so that the filter can be used for other purposes as well (and for cleaner code without the additional if statement).

Works with GravityView 2.21 as well.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.