Support » Plugin: Mailchimp for WooCommerce » Feature Request Allow Admins to set Capabilities

  • Resolved Howdy_McGee

    (@howdy_mcgee)


    Hello,

    Currently before the Mailchimp account is connected permissions seem to be set to manage_options per mailchimp_get_allowed_capability(). I don’t see where this can be changed before connecting the Mailchimp account. For websites where clients don’t have full permissions this can be a bit of a pain point. Currently, our clients are Editors with increased user permissions but this does not include manage_options.

    A possible solution for this could be a filter hook, a custom capability, or simply manage_woocommerce.

    Hopefully that makes sense but should you have any questions or need further clarification please let me know. Thanks again for putting together a great plugin!

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Support khungate

    (@khungate)

    @howdy_mcgee, thanks for reaching out and appreciate the kind words. We do have the ability in the plugin to allow Shop Managers and Administrators permissions: https://a.cl.ly/ApujjPq9. Would this be an option for you?

    If not, I’ll share your request with the development team to see if there’s another option available.

    @khungate Thanks for the reply. The problem is that I don’t get to see those options until Mailchimp is connected. Whenever you install a fresh version of the plugin, the only Mailchimp option leads you to the connection page. No subpages underneath.

    This poses a problem if you want your client to connect and configure Mailchimp and they do not have the manage_option capability as seen in the mailchimp_get_allowed_capability() function.

    Plugin Support khungate

    (@khungate)

    @howdy_mcgee, the screenshot shared is available in step 2 of the setup process of the plugin. You’ll just need to click the “Optional Store Settings” down towards the bottom. Does that help?

    Howdy_McGee

    (@howdy_mcgee)

    @khungate Thanks again for the reply!

    I unfortunately don’t see that option. The core issue is that as an agency we may not have the Mailchimp Connection logins and would rather the given user of a specific role do the setup themselves. This means that we’ll be unable to get to step 2 which is an issue.

    I’ve provided a screenshot which may hopefully clear things up. You can see that there is currently no Mailchimp submenu options since Mailchimp is not connected. There also doesn’t appear to be a “Optional Store Settings” link or button.

    https://imgur.com/a/1wxC2s2

    Unless there’s a WooCommerce Mailchimp option I’m not seeing it seems paradoxical. I need to connect the users Mailchimp Account to manage user permissions but I want the user to connect their own Mailchimp Account except they don’t have the correct permissions so I need to connect the users Mailchimp Account…

    Plugin Support khungate

    (@khungate)

    @howdy_mcgee, thanks for providing the screenshot and context to your situation. Unfortunately, the plugin requires access to the Mailchimp account via OAuth; there’s no way around that step.

    Could your client give you proper user rights to access their account? https://mailchimp.com/help/manage-user-levels-in-your-account/. Depending on what you’ve been tasked to do, you could ask for Manager or Author access. From there, you could set up in the plugin.

    Howdy_McGee

    (@howdy_mcgee)

    @khungate Just to be clear this is not a bug, just a simple feature request. There’s no urgency or anything to this at all, just a strange situation we’ve run into. It’s something that we feel isn’t out of the realm of possibilities to build a fix for and so we’ve labelled the topic as a feature request for the developers consideration.

    – – – –

    In the original post above we were able to track back the permission issue. Without the Mailchimp connection it defaults to manage_options which is a high level permission. This permission gives the user access to things like Settings and the options.php admin page which allows them to modify the options table values directly. Not something an average user should have.

    This permission default comes from the mailchimp_get_allowed_capability() function. A filter hook could be beneficial here. Developers could hook into this and switch out the capability with something more suitable to the project.

    An additional solution could be to give the plugin base settings which the administrator can set without needing to connect Mailchimp and save this into the options table for later use. Gravity Forms is a good example for this, but Gravity Forms also has their own set of permissions that can be managed I suppose.

    – – – –

    Some background is that our clients do not have Administrator access and are given access to many aspects of WordPress through WordPress Capabilities. This allows us to prevent the user from modifying the core WordPress Settings but still allow them to do things like create posts, manage users, and manage certain plugins in which the plugin provides capabilities ( or filterable capabilities ) for. This means that the user doesn’t have the manage_options capability unfortunately.

    Howdy_McGee

    (@howdy_mcgee)

    The filter hook could look something like:

    function mailchimp_get_allowed_capability() {
    	
    	$capability = 'manage_options';
    	
    	if( current_user_can('manage_woocommerce') && mailchimp_get_option('mailchimp_permission_cap') == 'manage_woocommerce' ) {
    		$capability = 'manage_woocommerce';
    	}
    	
    	return apply_filters( 'mailchimp_allowed_capability', $capability );
    	
    }

    On a sidenote, the reason the first conditional does not run is because:

    mailchimp_get_option('mailchimp_permission_cap')

    Which doesn’t appear to be set until after the Mailchimp Account has been connected and you have actual access to the Mailchimp settings page.

    Plugin Support khungate

    (@khungate)

    Gotcha ok @howdy_mcgee, I’ll be happy to pass this suggestion along to the team for consideration. I can’t be sure if or when it’ll be implemented, but we’ll be glad to keep you posted on any new developments. To help with following updates about the feature request, I’ve opened up a new GitHub ticket that you can subscribe to; as things progress you’ll receive further updates. I’ll go ahead & close this out for now to avoid any duplication, don’t hesitate to reach out if you need any other help.

    Thanks again for your feedback!

    • This reply was modified 6 months ago by khungate.

    For future readers, we ended up switching to “WP WooCommerce Mailchimp” which allows Shop Managers to manage their lists and settings out of the box, no hassle. It seems like a suitable alternative to the described issue.

    Plugin Author ryanhungate

    (@ryanhungate)

    @howdy_mcgee we’re actually going to be adding your suggestion with the filter for the manage options issue you brought up – and we’ll update this ticket when it’s done.

    I do realize that you’re already using another plugin which is totally fine – but we did want you to know that we’re looking at our next release objectives right now and this made it to the plate.

    We’ll send an update here when it’s on the way 🙂

    Thank you for the update! For future readers, the added hook:

    /**
     * Change the Mailchimp Management capability
     * 
     * @param String $capability = 'manage_options'
     * 
     * @return String
     */
    function prefix_mailchimp_cap( $capability ) {
    	return 'manage_woocommerce';
    }
    add_filter( 'mailchimp_allowed_capability', 'prefix_mailchimp_cap' );
Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.