Using Gravity Forms ‘gform_encrypt_password’ PHP filter

The gform_encrypt_password filter in Gravity Forms allows basic encryption of the password field.


add_filter('gform_encrypt_password', 'your_function_name', 10, 3);


  • $encrypt_password (bool): Whether to encrypt the Password field with true or false. The default is false.
  • $field (Field Object): The field object.
  • $form (Form Object): The form object.

More information

See Gravity Forms Docs: gform_encrypt_password


Enable Password Encryption

Enable password encryption for all forms.

add_filter('gform_encrypt_password', '__return_true');

Encrypt Password for Specific Form

Encrypt password only for the form with an ID of 53.

add_filter('gform_encrypt_password', 'encrypt_password', 10, 3);

function encrypt_password($encrypt_password, $field, $form) {
    if ($form['id'] == 53) {
        $encrypt_password = true;
    return $encrypt_password;

Encrypt Password Based on Field Label

Encrypt password if the field label is “Secure Password”.

add_filter('gform_encrypt_password', 'encrypt_based_on_label', 10, 3);

function encrypt_based_on_label($encrypt_password, $field, $form) {
    if ($field['label'] == 'Secure Password') {
        $encrypt_password = true;
    return $encrypt_password;

Encrypt Password if Form Title Contains “Secure”

Encrypt password if the form title contains the word “Secure”.

add_filter('gform_encrypt_password', 'encrypt_based_on_form_title', 10, 3);

function encrypt_based_on_form_title($encrypt_password, $field, $form) {
    if (strpos($form['title'], 'Secure') !== false) {
        $encrypt_password = true;
    return $encrypt_password;

Disable Password Encryption for Specific Form

Disable password encryption for the form with an ID of 60, even if it’s enabled globally.

add_filter('gform_encrypt_password', 'disable_encryption_for_form', 10, 3);

function disable_encryption_for_form($encrypt_password, $field, $form) {
    if ($form['id'] == 60) {
        $encrypt_password = false;
    return $encrypt_password;

Note: Place the provided code examples in the functions.php file of your active theme.