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
| Parameter | Type | Description |
|---|---|---|
$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
Change the Slack username for a specific form.
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 can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?
Since
This filter was added in version 1.3.
Source Code
This filter is located in GFSlack::process_feed() in class-gf-slack.php.