Changing color-code attached to a membership..?

Hi,

So, this seems really like it should be trivially easy, only ... I can't find a setting for it anywhere. I have two memberships (id 1669 and 1670) that have identical color-coding in the back end. This is confusing to my client, who is the primary back-end user. I want to change the color setting for either of the two memberships – I really don't care which, but I want to be sure it isn't changed to some other color used by some other membership.

Where, o WHERE, is the color-code assigned when a new membership is created? Where, o WHERE, can I change that color value? (the value in question, in case it matters, which I can't imagine it possibly does, is #8758c4. )

Back end access has already been granted, for another open ticket, and will not lapse for several weeks.

Your speedy response gratefully appreciated,
:Benjamin

  • Swapnil
    • The Incredible Code Injector

    Hi benjamin_barnett,

    Hope you're well.

    This definitely can be done with some custom code. The colour is created based on the actual membership id & type.

    We could change this by doing the following:

    Openup & edit /wp-content/plugins/membership/app/model/class-ms-model-membership.php

    Find the following function:

    public function get_color() {
    		return MS_Helper_Utility::color_index( $this->type . $this->id );
    	}
    replace with:
    
    public function get_color() {
            $color = '';
            switch($this->id) {
                case 101:
                    $color = '#ffffff';
                    return $color; // returns color as white for membership_id 101
                    break;
                case 102:
                    $color = '#000000';
                    return $color;  // returns color as black for membership_id 102
                    break;
    
                default:
                    return MS_Helper_Utility::color_index( $this->type . $this->id );
                    break;
            }
    	}

    Then in each case: change the value of $color = ''; in the above code& the number next to case is the id of the membership.

    That should then automatically change the colour to what you assigned in the above.

    Apologies for this being a hack, I have added this as a feature request so we will add a filter to that function, this will then mean it could be done in a custom filter without the need for editing the plugin.

    Alternatively, you can add the below code to your functions.php file for your theme or make a mu-plugin so the customizations are not lost every time you update the plugin.

    Could you please try this code in your child themes functions.php file? You can also place this in a mu-plugin with a starting:

    <?php

    tag.

    function membership_change_colors() {
    $color = '';
    switch($this->id) {
    case 101:
    $color = '#ffffff';
    return $color;
    break;
    case 102:
    $color = '#000000';
    return $color;
    break;
    default:
    return MS_Helper_Utility::color_index( $this->type . $this->id );
    break;
    }
    }

    add_filter('ms_model_membership_get_color', 'membership_change_colors');
    You will need to replace the current IDs with your membership IDs.

    Hope this helps. Please let me know if I can assist you with any further inquiry.

    Cheers,
    Swapnil V. Patil

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.