Using Gravity Forms ‘gform_shortcode_login’ PHP filter

The gform_shortcode_login filter in Gravity Forms is a dynamically generated hook name related to the User Registration Add-On. It is based on the gform_shortcode_{ACTION} hook, where the “ACTION” part is replaced with “login”. For more details, refer to gform_shortcode_{ACTION}.

Usage

add_filter('gform_shortcode_login', 'customize_login_form', 10, 3);

function customize_login_form($output, $atts, $content) {
    // your custom code here
    return $output;
}

Parameters

  • $output (string): The original login form output.
  • $atts (array): An array of attributes used in the shortcode.
  • $content (string): Any content wrapped within the shortcode.

More information

See Gravity Forms Docs: gform_shortcode_login

Examples

Change the submit button text

Customize the login form by changing the submit button text.

add_filter('gform_shortcode_login', 'change_submit_button_text', 10, 3);

function change_submit_button_text($output, $atts, $content) {
    $output = str_replace('value="Log in"', 'value="Sign in"', $output);
    return $output;
}

Add a custom message to the login form

Add a custom message above the login form.

add_filter('gform_shortcode_login', 'add_custom_message', 10, 3);

function add_custom_message($output, $atts, $content) {
    $message = '<p><strong>Welcome back!</strong> Please log in to continue.</p>';
    $output = $message . $output;
    return $output;
}

Hide the “Remember me” checkbox

Remove the “Remember me” checkbox from the login form.

add_filter('gform_shortcode_login', 'hide_remember_me', 10, 3);

function hide_remember_me($output, $atts, $content) {
    $output = preg_replace('/<span class="gform_remember_me">(.*)<\/span>/', '', $output);
    return $output;
}

Add a custom class to the login form

Add a custom CSS class to the login form.

add_filter('gform_shortcode_login', 'add_custom_class', 10, 3);

function add_custom_class($output, $atts, $content) {
    $output = str_replace('<form', '<form class="my-custom-class"', $output);
    return $output;
}

Redirect users after login

Redirect users to a custom page after successful login.

add_filter('gform_shortcode_login', 'custom_login_redirect', 10, 3);

function custom_login_redirect($output, $atts, $content) {
    $redirect_url = 'https://example.com/welcome';
    $output = str_replace('">', '" data-redirect="' . $redirect_url . '">', $output);
    return $output;
}