• Resolved gbotica

    (@gbotica)


    Hi, I’m working on a WooCommerce site, lots of plugins, including Mailchimp for WooCommerce. All been working fine, I use WP-CLI for some maintenance tasks etc.

    Recently, any WP-CLI command that actually loads the WP environment, e.g. wp plugin list generates this message (WP-CLI command fails… well, nothing happens…) :

    {"success":false,"data":{"message":"You're not allowed to do this","from":"mailchimp-for-woocommerce"}}

    This message is in /mailchimp-for-woocommerce/admin/class-mailchimp-woocommerce-admin.php:2338

    Even if I deactivate the plugin(!), any WP-CLI results in the above message. Only removing the plugin completely makes WP-CLI work again.

    As a temp work around I can use (this works!):

    wp user list --skip-plugins=mailchimp-for-woocommerce

    The above works, but I need to resolve this in the longer term. Has anyone else got this issue? Is this a bug in mailchimp-for-woocommerce?

    Any help appreciated! Thank you.

    • This topic was modified 3 months, 2 weeks ago by gbotica.
Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author ryanhungate

    (@ryanhungate)

    @gbotica hmm that’s interesting. If you don’t mind, you can try enabling the “debug” logs on the plugin and that would show you where the trace is originating from. Typically this happens when a user isn’t allowed to manage woocommerce. This function below is what gets called while executing admin related actions, so we have a filter you might need to use for custom roles. Also if you’re still seeing this while the plugin is deactivated I would wonder if there’s any caching going on that might need to be excluded? We’ll get you through this somehow but very curious on why you’re seeing that now.

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

    (@gbotica)

    Hi, Thanks for your response. I’ve checked caching bydisabling and clearing etc … I don’t think that’s the issue here. I do have User Role Editor installed and I’ve checked that Adminisrators have all permissions.

    WP-CLI loads all installed plugins (not just “active” ones), so that’s why it happens even when the plugin is disabled.

    I think perhaps I need to get the client to disconnect and reconnect to their Mailchimp account, as I don’t see any option to activate debug in this plugin, or do you mean WP_DEBUG?

    Thread Starter gbotica

    (@gbotica)

    Hi,

    Updating on this. The client has just re-connected to their MailChimp account, but no difference.

    Could you please provide details on how I enable debug logging for this plugin? I can’t see an option in the WP Dashboard – or does it need to be done with a filter?

    I’m not sure if another plugin on this site is somehow raising this issue, and causing thie permissions failure message from Mailchimp for WooCommerce, but as it stands, if I have this plugin installed, WP-CLI is completely broken. ??

    Plugin Author ryanhungate

    (@ryanhungate)

    @gbotica the debug option for logging is in the “LOGS” tab – where right above the logs we show you have the ability to select the debug option. All that’s going to do is add a trace to the log file which will show you what happens if you run that CLI command. That should help ( all of us ) understand where that’s coming from and how to resolve it. ( edited for log tab )

    • This reply was modified 3 months, 2 weeks ago by ryanhungate.
    Thread Starter gbotica

    (@gbotica)

    Hi, It seems I’m not seeing the Mailchimp Admin pages, I have no tabs, no debugging option, I think the same permissions issue is manifesting in the Dashboard as well.

    I’ve been looking directly in the database and the source code for this plugin… and there seems to be lots of possibly redundant stuff in the wp_options table, perhaps from an earlier version of this plugin or something. For example I have two records in wp_options, “mailchimp-woocommerce” and “woocommerce_mailchimp_settings” which both seem to be a JSON object of options for the plugin. This this plugin change slug at some point?

    I assume that “mailchimp-woocommerce” is the correct options object. So, I noticed that “mailchimp_permission_cap” was set to “manage_options”, but thought this should probably be “manage_woocommerce”, so I’ve edited it (also set the “mailchimp_debugging” boolean, but I don’t see any difference, I still have all the same issues. I cleared all caches etc.

    Thread Starter gbotica

    (@gbotica)

    FYI, this is what out Mailchimp for WooCommerce options page looks like… no tabs, no log, no debug option… something seems not right?
    https://www.awesomescreenshot.com/image/49294609?key=a978c673f2ec13be2ad42e8107e4a7aa

    Plugin Author ryanhungate

    (@ryanhungate)

    @gbotica that’s the screen before the plugin has done anything – you must click the sync button to get to the next screens / tabs etc.

    Thread Starter gbotica

    (@gbotica)

    Thanks, so I think our options page is also broken – clicking Sync doesn’t do anything, just reloads the same page.

    I think I’ll need to clone this site and deactivate all plugins etc to try and find what’s going on.

    Plugin Support khungate

    (@khungate)

    Hi @gbotica, it does indeed sound like a plugin conflict. Please let us know if you can pinpoint anything, and we’ll be happy to help troubleshoot further if needed. Also, if you haven’t already seen, we just released the latest version of the plugin today (4.2). While this update may not resolve your current issue, we encourage you to update to benefit from the latest improvements and fixes.

    Plugin Support khungate

    (@khungate)

    Hi @gbotica, we just wanted to check back with you to see if this was still a problem with our latest plugin (v4.2.1 at the time of this post). Please let us know when you get a moment, we’ll be happy to help troubleshoot further if necessary.

    I run into a similar, perhaps related, issue every time I update the plugin. On my first page load or attempt to do something with WP-CLI, I get the same JSON feedback reported above:

    {"success":false,"data":{"message":"You're not allowed to do this","from":"mailchimp-for-woocommerce"}}

    This happens on a few different sites. Worth noting that “updating” the plugin is not being done via the WP interface or WP-CLI, but via Composer.

    Thread Starter gbotica

    (@gbotica)

    Hi, I have just been working around this by not loading the mailchimp plugin in my wp-cli.yml:

    path: files/public
    skip-plugins: mailchimp-for-woocommerce

    I just removed the skip-plugins and tried again, but same permissions error as before.

    wp plugin list
    {"success":false,"data":{"message":"You're not allowed to do this","from":"mailchimp-for-woocommerce"}}

    provided I use skip-plugins I can run wp-cli:

    wp plugin list | grep mailchimp
    contact-form-7-mailchimp-extension active none 0.5.72 off
    mailchimp-for-woocommerce active available 4.2 4.2.1 off
    woocommerce-mailchimp-integration active none 1.0.3 off

    • This reply was modified 2 months, 2 weeks ago by gbotica.
    Plugin Support khungate

    (@khungate)

    @gbotica thanks for your patience. After further investigation, the issue you’re encountering with the WP-CLI is due to the default –user value being NULL, which is causing the check to fail. Our team has addressed this in the upcoming version 4.3, where the check will no longer fail under these circumstances. We hope to push this out in the next few weeks.

    In the meantime, you can resolve this issue by specifying the proper admin user with the –user flag. You can refer to the WP-CLI handbook documentation for more details on how to set this flag.

    Let us know if you need further assistance!

    Thread Starter gbotica

    (@gbotica)

    @khungate Awesome! Thanks for fixing the issue.

Viewing 14 replies - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.