Posted: August 1, 2019 at 10:18 am
Hi Thanks |
|
Hi there, You can use a function like this one: https://gist.github.com/Pebblo/f952f806aec55df5f8a1 Note that on line 10 it checks for the |
|
Just to clarify what Tudor was asking about since I have a similar need. I would like users who are registered with my “company” usergroup to only have the option to pay via invoice or credit card and then users who have registered as “individuals” to pay by credit card only. How might I manipulate the code you linked to in order to make that happen? I would assume I would change the code on line 10… to the following for the individuals… For companies I would guess it might look something like this… Please let me know if I am on the correct line of reasoning or if I am incorrect. Thank you for the help in advance. |
|
The above is incorrect.
So
The capability check does not affect the payment methods themselves, it’s just a conditional for you to load the code that will add/remove payment methods so The filter is passed an array of payment method objects that would normally load on every event, so you’ll have both Invoice and Stripe enabled, meaning they will be within that array but the tough part of this is the array will use the payment method IDs as the keys of the array which means the array will be unique for each site. What I would do is move the capability check from Line 10 down inside the EE_Transaction condition and filter the |
|
Thank you for the response Tony! My apologies for not understanding. |
|
My need is very similar to Tudor’s, I just want the members of the company usergroup to be able to use the invoice payment method. I don’t understand what changes to make to the function you supplied to make that happen. Based on your first response it sounded like on line 10 I should change the “manageoptions” cap but I am not sure what it should be changed to or how this function knows what usergroup to look for. |
|
Your need is very different from Tudors. From Tudor’s opening post:
So they need to add the ability to select Invoice for users with a specific capability whilst leaving the current payment method available, which in short was simply a case of changing that capability check as it already adds an invoice payment method if your an admin, so that just changes ‘if your an admin’ check to a different capability and injects an additional payment method. You need to set specific payment methods based on the user’s capability, that’s very different to Tudors request and you need to customize the function I provided as an example, it’s not a case of simply swapping out that capability as it was for Tudor.
Remove the capability check from line 10, so it would just be:
Then within the
Check the user capability and add/remove the payment methods you need from there. So inside that, you may have something like:
As you can see, because you want to show/hide payment method based on the user its not a simple as swapping out a conditional. |
|
The support post ‘Hiding payment method(s) for certain user roles’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.