Stripe Cancellation Form autoFocus

I want to embed my stripe cancellation form into my sales page, but there seems to be some sort of autofocus attribute on one of the inputs in the form that is making the page scroll to the unsubscribe form on load. I’m not certain this is what’s causing it, because I haven’t been able to find it, but when I go to this page https://www.schooloflifedesign.com/sales-page-test/ (pw: 1234), it automatically loads on the unsubscribe form.

Does anyone know why this is? I’m using my own modified template, and I looked all through the template for something with autofocus on, but couldn’t find anything.

Thanks in advance!

Also, I forgot to mention that I’m certain that it’s form that’s causing it, because when I delete the shortcode, the page loads at the top.

Hi @kellycree. I can take a look at it but it is a password protected page. You can message me the pwd directly via this forum’s profile messaging mechanism.

1 Like

Hi @onepresstech, thank you so much! As I mentioned in my post, the pw is 1234. Thanks again!

Sorry…i missed that. Unfortunately…pwd 1234 does not access the page…it just stays as a pwd-protected page. Tried it with latest firefox and chrome in Windows10. Can you doublecheck the pwd works for you. Cheers.

Ugh! Sorry for the annoyance, not sure what was up with that. I just made it public. Thanks again for looking!

I took a look at the code and it looks like it is jumping to the form because it is evaluating whether the user is logged in or not AND if the user is not logged in it is displaying the “You must log in to cancel your account”. So the display of the error message is triggering the autoscroll.

To get around this try the following (should work but no promises…it’s an educated guess):

wrapper the s2member shortcode with [s2if]…e.g.

[s2If is_user_logged_in()]
    ...your form...
[/s2If]
1 Like

Thank you so much, that information is very helpful. Unfortunately, that solution didn’t fix it, but it’s good to know what’s causing it. I will look further into that, thank you!

Hmmm…it should have worked. I may be wrong as to the cause. It could be the captcha.

Can you put the nested form up on your test site so I can take a look at it.

[s2If is_user_logged_in()]
    ...your form...
[/s2If]

I realized it was because I was logged in! So it did work, thank you so much!

Which solves it for many cases, but then it’s still weird if they navigate to that page and they are logged in but not looking to unsubscribe. Do you know if there’s a way to make it so that alert doesn’t autoscroll?

Thanks again for all your help!

Glad it worked :slight_smile:

If the user is logged in then there is no message. No message, no auto-scroll.

If the user is not logged in then there is no form since the [s2If is_user_logged_in()] [/s2If] wrapper hides it.

When the user is not logged in, yes it works perfectly.

If they are logged in, but not as a paid user, it gives an alert saying “Nothing to cancel. You’re NOT a paid Member.” (sg attached)

If they are logged in as a paid member, but they have already cancelled, the alert says “Nothing to cancel. You have NO recurring fees.” (sg attached)

The thought just occurred to me that I could use the s2member conditional logic to weed out those logged in users not in an s2member role (mainly Customer role), so the only time the alert would get served then is if they were a sub who already unsubscribed. That would be a pretty small amount of cases, but I’m still hoping to avoid that happening if possible. Do you have any thoughts on how to avoid or work around that case?

Thanks again for all your help!

The only way to make it foolproof would be to create a separate page for the unsubscribe form and put a link to it on this page. So the process becomes a two-keypress process (press link on this page + press button on next page). Given that it happens infrequently this would be considered acceptable UX.

1 Like

Actually…the following should work:

[s2If is_user_logged_in()]

[_s2If current_user_can(access_s2member_level1)]
    ...your form...
[/_s2If]

[/s2If]

NOTE: Notice the ‘_’ character in the inner shortcode. This is required.
NOTE2: you can use [_s2If current_user_can(access_s2member_level0)] if your model supports a free user level.

1 Like

I actually did get something similar to that work, I just used [s2If current_user_can(access_s2member_level1)], and that works great for that case.

I’m wondering if I can somehow use s2member_auto_eot_time to determine if the user already has an EOT and then don’t run the form if they do?

Something like, and I know this isn’t correct (it actually crashed my site haha) but:
[s2If current_user_can(access_s2member_level1) AND s2member_auto_eot_time(!= ’ ')]

I’ve been looking at this post Display content based on time until EOT, and I think I can use something similar to do what I want. From what I understand from this post, it seems like maybe I can’t do what I want with s2 conditionals and need to use PHP instead. But I don’t understand where in the template I would put the conditional.

Something like:
<?php
$eot_time = get_user_field(‘s2member_auto_eot_time’);
if (empty($eot_time)) {
}
?>

Does that even make sense?!

Do you have any thoughts on if I can use the EOT to achieve this either with the s2 conditionals or PHP?

I’m honestly about to give up and just put it on a separate page like you said, but I thought it was worth trying this one last thing.

Thanks again for all your help!

The double-nested one should work. Here are the cases:

  1. logged-in subscribed
  2. logged-in unsubscribed
  3. logged-out subscribed
  4. logged-out unsubscribed

The outer [s2If is_user_logged_in()] catches the first condition and the inner [_s2If current_user_can(access_s2member_level0)] catches the second condition.

So only combo #1 will display the form and with no warning message displayed so no auto-scroll.

Unfortunately, it still gives the alert if the user is logged in, has unsubscribed, but has not reached their EOT.

The alert says “Nothing to cancel. You have NO recurring fees.” (like the second sg above)

But you know what, I think it’s time for me to just give up and put it on a separate page.

Thank you again so much for all your help!

No worries. Interesting problem. The second page option is definitely the safest :slight_smile:

1 Like

I ended up just commenting out the alert in the template and it worked! Loads at the top of the page now. I realized that we were essentially trying to use conditionals to make the alert never appear, so I was like why not just get rid of the alert entirely.

Out of curiosity…what file are you referring to as “the template”?