Using Gravity Forms ‘gform_is_form_editor’ PHP action

The gform_is_form_editor Gravity Forms PHP filter allows you to mark pages as Form Editor pages or not.

Usage

add_filter('gform_is_form_editor', 'your_function_name', 10, 1);

Parameters

  • $is_form_editor (bool): Whether the page is a form editor page or not.

More information

See Gravity Forms Docs: gform_is_form_editor

Examples

Set a page as not a Form Editor page

This example sets the $is_form_editor variable to false, marking the page as not a Form Editor page.

add_filter('gform_is_form_editor', 'set_editor', 10, 1);

function set_editor($is_form_editor) {
    return false;
}

Keep a page as a Form Editor page

This example keeps the $is_form_editor variable unchanged, maintaining the page as a Form Editor page.

add_filter('gform_is_form_editor', 'keep_editor', 10, 1);

function keep_editor($is_form_editor) {
    return $is_form_editor;
}

Mark a page as a Form Editor page based on a condition

This example sets the $is_form_editor variable to true if the current user has the role of “editor”.

add_filter('gform_is_form_editor', 'conditional_editor', 10, 1);

function conditional_editor($is_form_editor) {
    if (current_user_can('editor')) {
        return true;
    }
    return $is_form_editor;
}

Set a page as a Form Editor page only for admin users

This example sets the $is_form_editor variable to true if the current user is an admin, otherwise, it keeps the original value.

add_filter('gform_is_form_editor', 'admin_editor', 10, 1);

function admin_editor($is_form_editor) {
    if (current_user_can('administrator')) {
        return true;
    }
    return $is_form_editor;
}

Disable Form Editor for non-admin users

This example sets the $is_form_editor variable to false for non-admin users, disabling the Form Editor for them.

add_filter('gform_is_form_editor', 'disable_editor', 10, 1);

function disable_editor($is_form_editor) {
    if (!current_user_can('administrator')) {
        return false;
    }
    return $is_form_editor;
}