Gateway conditionals in custom profile pages

Hi!

I’m trying to set up my custom user profile pages so that they only display the payment/cancellation information for the gateway the user paid with when they subscribed.

Basically, if the user subscribed with PayPal, the profile page should only show their PayPal options (not Stripe or any other gateway).

I understand this can be done by using current_user_gateway_is(gateway) however I’m unclear on what the gateway names are. Are these correct?

  • current_user_gateway_is(paypal)
  • current_user_gateway_is(stripe)

Thanks!
Luis

here’s the code concerned from s2member/src/includes/functions/api-functions.inc.php

/**
* Conditional to determine if the current User has a specific gateway set in his profile.
*
* ———— PHP Code Sample ————
* ```
* <!php
* if(current_user_gateway_is("stripe"))
*       echo "Current user's payment gateway is set to Stripe (e.g. last paid through s2's Stripe pro-form)";
* !>
* ```
*
* ———— Shortcode Conditional Equivalent ————
* ```
* [s2If current_user_gateway_is(stripe)]
*       Current user's payment gateway is set to Stripe (e.g. last paid through s2's Stripe pro-form)
* [/s2If]
* ```
*
* @package s2Member\API_Functions
* @since 220316
*
* @param string $gateway A gateway ID *( e.g. `stripe`, `paypal`, `authnet`, `clickbank` )*.
* @return bool True if the specific User has the specified gateway, else false.
*/
if (!function_exists("current_user_gateway_is")) {
    function current_user_gateway_is($gateway) {
        return ($gateway === S2MEMBER_CURRENT_USER_SUBSCR_GATEWAY);
    }
}
1 Like

Hey Gerard, thank you for the response. I have a few questions:

  1. Does this mean the gateway shortcode only tells users they paid through the gateway?
  2. Is there a shortcode for the paypal gateway? If yes, then what would that be?

I’m going to test this on my custom profile pages in a moment.

Thanks again!

This shortcode conditional is used like so:

[s2If current_user_gateway_is(stripe)]
This content will only be shows if the current user’s payment gateway is Stripe.
[/s2If]

[s2If current_user_gateway_is(paypal)]
This content will only be shows if the current user’s payment gateway is Paypal.
[/s2If]

1 Like

See also:

  • Does this mean the gateway shortcode only tells users they paid through the gateway?

When you use the conditinoal [s2If current_user_gateway_is(stripe)], only those users that have in their profile Stripe as the gateway they paid through, will be shown what’s inside that s2If block.

1 Like

Hey, thank you both for the helpful clarifications, I’m now in the process of revamping my custom profile pages and they’re looking pretty cool. I’ll test the funnel for each of my tier/gateway options and see if the process is smooth from start to finish.

Thanks again for the assist!

1 Like