• Resolved Shane Gowland

    (@thewebatom)


    Hi,

    Our site has three “customer” roles. There’s Customer, Expired Customer, and Pending Customer.

    Unfortunately, Notifications is lumping the expired and pending roles together with the customer role, leading to emails being sent to an incorrect number of users.

    You can see that the number of Customer accounts reported by WordPress is different from the number of Customer accounts reported by your plugin.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Kuba Mikita

    (@kubitomakita)

    Hi Shane,

    the reason for that is because these customers are not separate roles. It’s one role probably with meta saved in user profile which makes it expired or pending.

    So 321 customers are 286 users without meta + 14 customers with expired meta + 21 customers with pending meta.

    That’s rather interesting way of doing this but this third party plugin, but we, unfortunately, cannot help it. Another custom recipient type which would integrate with this plugin is needed.

    Thread Starter Shane Gowland

    (@thewebatom)

    Hi Kuba,

    Thanks for the prompt response.

    I’m quite sure they’re actually separate custom roles. As a quick test, I ran the following code:

      $editable_roles = get_editable_roles();
        foreach ($editable_roles as $role => $details) {
            $sub = translate_user_role($details['name']);
            echo $sub . '<br>';
        }

    Which produced this output:

    Administrator
    Customer
    Shop Manager
    Expired Customer
    Shop Assistant
    Pending Customer
    On Hold

    Plugin Author Kuba Mikita

    (@kubitomakita)

    Hmm, this is exactly the way we are doing it, see: https://github.com/BracketSpace/Notification/blob/develop/class/Defaults/Recipient/Role.php#L64

    Do you see the Expired Customer and Pending Customer in the Role recipient select?

    Thread Starter Shane Gowland

    (@thewebatom)

    Yes, the other roles show up in the recipient select dropdown with the correct user counts.

    Plugin Author Kuba Mikita

    (@kubitomakita)

    Ok, what’s this plugin you are using?

    Thread Starter Shane Gowland

    (@thewebatom)

    As far as I can tell, they’ve just been created with Capability Manager Enhanced.

    No plugins reference the pending customer role. The only place I can see it used is in the theme—there’s a helper function in functions.php

    function is_user_pending_customer($user) {
    
        if ( isset( $user->roles[0] ) && $user->roles[0] == 'pending_customer' ) {
            return true;    // when user is a pending customer
        } else {
            return false;   // when user is not a pending customer
        }
    }

    is_user_pending_customer() is then used throughout the theme template to hide certain parts of the webpage from people in that user role.

    Plugin Author Kuba Mikita

    (@kubitomakita)

    That makes sense.

    I looke into our code and I spotted a bug. See this how we are making the users query: https://github.com/BracketSpace/Notification/blob/develop/class/Traits/Users.php#L56

    The %customer% LIKE statement is matching the pending_customer and customer_suffixed so the results seem to be right for the code. But that’s certainly now how it should be!

    Let me fix that. The patch should be available maybe even today. I can provide a development version if you’d like to install it or send you the changelog so you could add it by yourself.

    Thread Starter Shane Gowland

    (@thewebatom)

    Hi Kuba,

    That’s great news! (well, not the bug, but that you spotted it)

    I’m happy to pull the new file from GitHub when you have it ready, just give me a heads-up in this thread.

    Thanks for your help ??

    Kind regards,

    Shane

    Plugin Author Kuba Mikita

    (@kubitomakita)

    Shane, the fix was easier than I expected ??

    Here is the changeset and corrected file.

    Let me know if it fixed the issue

    Thread Starter Shane Gowland

    (@thewebatom)

    I can confirm the fix is working as expected. Thank you so much for taking care of this so quickly.

    Plugin Author Kuba Mikita

    (@kubitomakita)

    Perfect! Thanks for the update ??

    If you are happy with the plugin and support, could you please post a short review?

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Issue with recipient roles’ is closed to new replies.