Using Gravity Forms ‘gform_slack_invite’ PHP filter

The gform_slack_invite Gravity Forms PHP filter allows you to modify the invite user parameters before the invite is sent to Slack.

Usage

To apply the filter to all forms:

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

To target a specific form, append the form ID to the hook name (format: gform_slack_invite_FORMID):

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

Parameters

  • $invite (array): Invite parameters.
  • $feed (Feed Object): The current feed object.
  • $entry (Entry Object): The current entry object.
  • $form (Form Object): The current form object.

More information

See Gravity Forms Docs: gform_slack_invite

Examples

Change team name

Modify the team name in the invite parameters:

add_filter('gform_slack_invite', 'change_invite', 10, 4);
function change_invite($invite, $feed, $entry, $form) {
    $invite['team'] = 'rocketgenius';
    return $invite;
}

Set custom channel

Set a custom channel for the invite:

add_filter('gform_slack_invite', 'set_custom_channel', 10, 4);
function set_custom_channel($invite, $feed, $entry, $form) {
    $invite['channel'] = 'custom-channel';
    return $invite;
}

Add expiration date

Add an expiration date to the invite:

add_filter('gform_slack_invite', 'add_expiration_date', 10, 4);
function add_expiration_date($invite, $feed, $entry, $form) {
    $invite['expiration'] = strtotime('+7 days');
    return $invite;
}

Set custom role

Set a custom role for the invited user:

add_filter('gform_slack_invite', 'set_custom_role', 10, 4);
function set_custom_role($invite, $feed, $entry, $form) {
    $invite['role'] = 'custom-role';
    return $invite;
}

Modify email

Modify the email address before sending the invite:

add_filter('gform_slack_invite', 'modify_email', 10, 4);
function modify_email($invite, $feed, $entry, $form) {
    $invite['email'] = '[email protected]';
    return $invite;
}