Control Gravity Forms Field Visibility Based on MemberPress Membership Status

I’m working with a Gravity Forms setup where I need to control field visibility depending on whether a user holds an active MemberPress membership. My plan is to create a hidden field that gets automatically filled when the system detects an active membership, then use this populated field to trigger conditional logic for other form elements.

I found that I can verify membership status using MemberPress functions, but I’m stuck on the next step. How do I automatically set a value in a specific form field when the membership check returns true?

Here’s the membership verification code I’m working with:

$member_obj->has_active_subscription( $subscription_id ); // returns true or false

What’s the best way to populate a form field programmatically based on this membership validation result?

Those PHP solutions work, but you’re creating maintenance nightmares. Every WordPress update or theme switch means more code tweaking.

I handle this differently. Instead of hardcoding PHP filters, I built an automation that watches MemberPress membership changes in real time and updates form behavior instantly.

Membership status changes? The automation fires immediately, checks their current status, and adjusts which form fields they see. No delays, no cache issues, no broken conditional logic.

Best part? Set it up once through a visual interface. No more digging into functions.php or dealing with hook conflicts. You can extend it to send notifications, update other systems, or trigger workflows based on membership changes.

I’ve used this across multiple client sites. It’s rock solid and way easier to manage than custom PHP. When you need to modify the logic later, just drag and drop instead of debugging code.

Check out Latenode for this kind of automation: https://latenode.com

Another approach is the gform_field_value hook - might be simpler for what you need. Toss this in your functions.php and it’ll auto-populate the hidden field:

add_filter('gform_field_value_membership_status', 'check_member_status');
function check_member_status($value) {
    if(is_user_logged_in()) {
        $user = mepr_get_current_user();
        return $user->has_active_subscription(123) ? 'yes' : 'no';
    }
    return 'no';
}

Just set your hidden field’s parameter name to ‘membership_status’ in the form editor and you’re good to go.

To achieve your goal, you can utilize Gravity Forms’ gform_pre_render filter to set the hidden field’s value based on the user’s membership status before the form is rendered. You should implement a function that checks whether the user is logged in and subsequently verifies their active subscription using your existing code. Here’s a snippet that can help you:

add_filter('gform_pre_render_1', 'populate_membership_field'); // replace 1 with your form ID
function populate_membership_field($form) {
    if(!is_user_logged_in()) return $form;
    $user = mepr_get_current_user();
    $subscription_id = 123; // your subscription ID
    foreach($form['fields'] as &$field) {
        if($field->id == 2) { // change to your hidden field ID
            $field->defaultValue = $user->has_active_subscription($subscription_id) ? 'active_member' : 'inactive_member';
        }
    }
    return $form;
}

Set your conditional logic in Gravity Forms to display or hide fields based on the hidden field’s value, ensuring it is populated before the conditional checks are made.