Hide an option to add manually members to a paid membership

Currently, while manually adding members to a paid Membership, will grant access for life, it never lets them pay. This bug is reported.

Please advise how it is possible to temporary hide/remove an option that adds manually users to a paid membership?

I have two memberships that need to be given manually, paid and free. I would like to have the option to add manually members to a free membership but not the paid one.

Please advise

  • Panos

    Hi Sarah ,

    You could try adding the following snippet in your functions.php or a mu-plugin:

    add_filter( 'ms_view_member_editor_fields_edit', function( $fields ){
    
        $subscription_fields = $fields['subscriptions'];
    
        foreach( $subscription_fields as $key => $subscription_field ){
    
            // could check if $key != 4 but not sure it's safe
            if( ! isset( $subscription_field['id'] ) || $subscription_field['id'] != 'subscribe' ||
                ! isset( $subscription_field['type'] ) || $subscription_field['type'] != 'radio' ||
                ! isset( $subscription_field['field_options'] ) || ! is_array( $subscription_field['field_options'] )
            ){
                continue;
            }
    
            $unused_memberships = $subscription_field['field_options'];
    
            foreach( $unused_memberships as $membership_id => $membership_str ){
    
                $membership = MS_Factory::load(
                    'MS_Model_Membership',
                    $membership_id
                );
    
                if( ! $membership->is_free ){
                    unset( $fields['subscriptions'][$key]['field_options'][$membership_id] );
                }
    
            }
    
        }
    
        return $fields;
    }, 10 );

    Please let us know how this works for you :slight_smile:

    Thanks!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.