• Resolved billium99

    (@billium99)


    Hi! Love your plugin but I enabled View As and not View Admin As Default capability for Shop Managers, so they can’t view as Admin and wreak havoc. And we have two custom user types that are at or below customers in terms of capabilities. I notice that these custom user types are not selectable by Shop Managers unless I give Shop mgrs the “View Admin As Default: capabilities. Am I doing something wrong?

    Or is there a place for me to explicitly tell View As that Shop Managers can see these user types and view as them, but not Admins?

    Also I am dumbfounded how to get help from you via Slack. I have an account, but no invitation to your space, so I can’t login or hit you up in any sort of obvious way. (New Slack user, in case it’s not obvious haha)

    Thank you

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @billium99

    I’m not sure I completely follow what you are trying to do.
    What do you mean with “View Admin As Default: capabilities ?

    To use this plugin functionality the user needs some requirements: See: https://github.com/JoryHogeveen/view-admin-as/wiki/Custom-capabilities#view_admin_as

    However, there is no real hierarchy in the WordPress role system, there are just capabilities and roles are basically groups of capabilities.

    As for Slack, you can opt-in yourself but since there is barely any activity that I also rarely check it. ??

    Please explain your situation more in depth so I might have a solution!

    Cheers, Jory

    Thread Starter billium99

    (@billium99)

    Hi Jory,

    Thanks for the reply. Yes I have a Shop Manager who cannot view my newly created Summer and Lifetime user roles. Shop Manager has edit_user capabilities and all other Shop Manager defaults too. But when I log in as a Shop Manager (not view as – full login) and try to search for a Summer user role user or Lifetime user role user, I get no results found. Please see screen shot:

    Any suggestions?

    Thank you!

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @billium99

    Just to be sure, there are also no results if you just input “scanlon” and nothing more?

    Just went through the code that handles searching (it’s been a while) and compared it to the latest docs. From what I can tell the usage of this should not have changed.

    Did you try it with only this plugin active as well? Could be a plugin conflict.

    EDIT: Just noticed that the roles list also doesn’t include the Summer role. What did you use to create this role? And does it include any notable capabilities?

    Cheers, Jory

    Thread Starter billium99

    (@billium99)

    Well it’s more that it works perfectly for Administrator – I search “scanlon” and it pulls right up. But using View As, as a Shop Manager this same address search does not return the user with user role “Summer”. Are you still thinking that could be a plugin conflict? Works great for one user role and not another?

    OK so I just disabled everything including the theme. I’ve confirmed that Shop Manager has both View As capabilities as part of their profile. And Shop Manager just still cannot view/search for my two custom user roles. Those roles, again, have Read Posts capabilities and that’s it. Is there something I need to do within View As settings to enable these user role types to be viewable or “controllable” for Shop Managers?

    I recognize this is a free plugin, but it’s incredibly useful. Would you be willing to charge a bit of money to help me untangle the issue?

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @billium99

    Thank you for checking. Based on your findings I did some debugging myself.
    The user visibility is also determined by the editable_roles filter to check whether the current user is allowed to assign/modify a role (Besides the capability and admin checks). Note that you probably cannot edit the users you’ve mentioned when logged in as a Shop Manager, you can only see them in the list.
    More info about this filter here: https://developer.www.ads-software.com/reference/hooks/editable_roles/

    Since you mention Shop Manager I assume you are using WooCommerce. Are you sure you disabled WooCommerce in your tests? Because if I test locally with WooCommerce active I get the same results.
    This is because WooCommerce hooks into the editable_roles filter and if the current user is a Shop Manager it will only return the customer as an editable role.
    See: https://wp-kama.com/plugin/woocommerce/function/wc_modify_editable_roles

    Removing this hook fixes this issue in my local installation:

    remove_filter( 'editable_roles', 'wc_modify_editable_roles' );

    Please let me know if this also works for you. Though keep in mind that you should always be careful for access changes like this. Maybe in your specific case it’s better to just create a new role with the same capabilities as the Shop Manager and assign this only to specific users you are sure you want to grant access to these functions. Proper role management is very important for security when you have multiple users that can edit users.

    Since this filter is added by WooCommerce intentionally I will not include this change in this plugin, however, once you verify it works I will add it to do docs for anyone else encountering the same issue.

    Oh, and no need for payments of any sorts, this is support, not custom development ??
    Contributions, donations and/or positive reviews are always welcome of course!

    Cheers, Jory

    Thread Starter billium99

    (@billium99)

    Hi Jory – where are you placing that remove_filter because it’s not working for me. I’ve gone so far as to give Shop Managers 100% of the capabilities of Administrators using User Role Editor, and still my Shop Managers cannot search and find Summer or Lifetime users. And I apologize, you’re right that Woo was still running, since the next thing I need to test involved the Woo checkout with Shop Manager’s acting as Summer or LIfetime user role types. Literally everything else is shut down, but I can also see that your plugin works fine for Shop Managers viewing these custom user roles until WooCommerce is re-activated.

    I’ve tried adding your snippet directly in functions.php and even tried deploying a plugin, in case the timing of our remove_filter wasn’t happening late enough in the process. Still no dice.

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @billium99

    Since VAA runs very early you cannot do this in your theme.
    I think it’s best to either create a plugin or a mu-plugin for this with the following code:

    add_filter( 'editable_roles', function( $roles ) {
      remove_filter( 'editable_roles', 'wc_modify_editable_roles' );
      return $roles;
    }, 1 );

    Notice the “1” as a third priority parameter. This wil run this function before the one from WooCommerce so that it will always remove before it can run.

    Alternatively you could also leave the WooCommerce filter as is and modify the roles which a Shop Manager can edit:

    add_filter( 'woocommerce_shop_manager_editable_roles', function( $roles ) {
      $roles[] = 'Your role';
      $roles[] = 'Your second role';
      return $roles;
    } );

    Hope this helps!

    Cheers, Jory

    • This reply was modified 7 months, 4 weeks ago by Jory Hogeveen.
    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi?@billium99

    I didn’t get a reply from you anymore so I will assume that this issue is solved.
    Hit me up if you need help in the future! And of course, a nice review or contribution would be very much appreciated!

    Cheers, Jory

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘New User Types aren’t searchable for Shop Managers’ is closed to new replies.