Wondering if it is possible to add additional Subscription Status types?

I am wondering if we are able to additional Subscription Status types? By default, it comes with Active / Cancelled / Expired but we want to add 'deceased'. Well, we don't necessarily need deceased, but we do need one for SUSPENDED.
This is because some members violate our terms and we need to suspend their memberships. There are certain steps they can do to get their memberships back. So we would need a list of the suspended members. Please help.

  • Adam Czajczyk

    Hi Simon

    I hope you're well today and thank you for your question!

    Adding a "full featured" additional statuses wouldn't be that easy. It would require a lot of "under the hood" issues to be addressed and that would mean quite a lot of additional development on a plugin's core level.

    However, it might be possible to add some statuses in that sense that they'd actually be just "names" - so for example a "suspended" status would not affect a member in any way except temporarily blocking access (like removing membership at all) and just "naming" the status as "suspended", but not e.g. changing the end date of the payment. But that's only my opinion so far and I need to consult that with developers so I'm not making promises for now. I hope that's fine.

    Having that said, I passed the question to our developers and asked them about that. Please keep an eye on this ticket and we'll let you know if there's some reasonable solution to that (and if so, what could that be) or if it wouldn't be doable (or would require a whole complex custom development).

    Best regards,
    Adam

  • Panos

    Hi there Simon ,

    It's not that simple to add new status as it is being checked in several places in plugin code and will be hard to achieve and preserve after updates. I looked for available filters and they won't be helpful for this requirement. For this you would have to hire a skilled developer and it needs to be repeated on each plugin update.

    I would suggest a different approach here, which again requires some custom coding, so we can't support this fully. I'll provide snippet examples which you can use as a guide. These should be working properly, but would ban a member from all posts/pages that have protection enabled.

    After that being said, I would suggest to use a custom user meta field, eg ms_is_banned to flag a member as banned. Then we can use that in the ms_get_rule_value as in the following example snippet:

    add_filter( 'ms_get_rule_value', function( $value, $id, $rule_type, $ms_rule ){
    
    	if ( is_user_logged_in() ) {
    
    		$is_banned = get_user_meta( get_current_user_id(), 'ms_is_banned', true );
    		$is_banned = ( empty( $is_banned ) || ! $is_banned ) ? false : true; 
    
    		if (
    			$is_banned &&
    			is_scalar( $id ) &&
    			isset( $ms_rule->rule_value[ $id ] )
    		)
    		{
    			$value = false;
    		}
    	}
    
    	return $value;
    }, 20, 4 );

    Here is a simple sample snippet, providing a simple checkbox, to handle that meta field from a user's profile page in admin:

    function wpmudev_ms_banned_meta_field( $user ) {
    
    	if ( ! current_user_can( 'manage_options' ) ) {
    		return;
    	}
        ?>
        <h3>Ban member's access from protected pages</h3>
        <table class="form-table">
            <tr>
                <th>
                    <label for="ms_is_banned">Ban this member</label>
                </th>
                <td>
                    <input type="checkbox"
                           class="regular-text ltr"
                           id="ms_is_banned"
                           name="ms_is_banned"
                           value="1"
                           <?php checked( get_user_meta( $user->ID, 'ms_is_banned', true ), true ); ?> >
                    <p class="description">
                        If banned, member will not have access to protected content
                    </p>
                </td>
            </tr>
        </table>
        <?php
    }
    
    function wpmudev_ms_banned_meta_field_update( $user_id )
    {
    
        if ( ! current_user_can('edit_user', $user_id ) ) {
            return false;
        }
    
        $ban_user = isset( $_POST['ms_is_banned'] ) && $_POST['ms_is_banned'];
        if ( $ban_user ) {
        	return update_user_meta(
    	        $user_id,
    	        'ms_is_banned',
    	        true
    	    );
        }
        else {
        	delete_user_meta( $user_id, 'ms_is_banned' );
        }
    
    }
    
    add_action(
        'edit_user_profile',
        'wpmudev_ms_banned_meta_field'
    );
    
    add_action(
        'show_user_profile',
        'wpmudev_ms_banned_meta_field'
    );
    
    add_action(
        'personal_options_update',
        'wpmudev_ms_banned_meta_field_update'
    );
    
    add_action(
        'edit_user_profile_update',
        'wpmudev_ms_banned_meta_field_update'
    );

    You can paste the above snippets in mu-plugin. If you are not familiar with mu-plugins you can read about them here :
    https://premium.wpmudev.org/manuals/wpmu-manual-2/using-mu-plugins/

    Hope this was helpful!

    Kind regards!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.