gform_slack_username

Description

This filter is used to dynamically change the username the message is being sent by before it is sent to Slack.

Usage

The following would apply to all forms:

add_filter( 'gform_slack_username', 'your_function_name', 10, 4 );

To target a specific form append the form id to the hook name. (Format: gform_slack_username_FORMID)

add_filter( 'gform_slack_username_10', 'your_function_name', 10, 4 );

Parameters

  • $username string

    The current username being used for the Slack message. Default is: Gravity Forms.

  • $feed Feed Object

    The current feed object.

  • $entry Entry Object

    The current entry object.

  • $form Form Object

    The current form object.

Examples

This example changes the username for a specific form.

add_filter( 'gform_slack_username_4', 'change_slack_username', 10, 4 );
function change_slack_username( $username, $feed, $entry, $form ) {

    $username = 'Support Bot';

    return $username;

}

Placement

This code should be placed in the functions.php file of your active theme.

Since

This filter was added in version 1.3.

Source Code

gf_apply_filters( 'gform_slack_username', array( $form['id'] ), 'Gravity Forms', $feed, $entry, $form )

This filter is located in GFSlack::process_feed() in class-gf-slack.php.