Hi James,
Can you try this code to insert in the header custom code at APP LEVEL
You need to change the two window.location.href = 'https:............
and “useraccounts1” inside window.addEventListener('submit-form-success-useraccounts1'
. It should be the ID of your signin form.
<script>
window.addEventListener('submit-form-success-useraccounts1', () => {
const currentPageUrl = window.location.href;
_setCookie('signInUpRedirectionUrl', encodeURIComponent(currentPageUrl), 1);
setTimeout(() => {
const isMobileDevice = /Android|webOS|iPhone|iPad|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
if (isMobileDevice) {
window.location.href = 'https://test-play.softr.app/tab-features-only';
} else {
window.location.href = 'https://test-play.softr.app/tabs-for-softr-with-var-iterator-js-snippet';
}
}, 100);
function _setCookie(name, value, days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "expires=" + date.toUTCString();
document.cookie = name + "=" + value + ";" + expires + ";path=/;" + 'SameSite=Lax; Secure';
}
});
</script>
An other version would be
Here it doesn’t rely on a list of possible mobile devices (user agent) but on a maximum browser pixel width size (you can modify it by changing max-width: 768px
).
I personally do prefer this browser pixel width size method
<script>
window.addEventListener('submit-form-success-useraccounts1', () => {
const currentPageUrl = window.location.href;
_setCookie('signInUpRedirectionUrl', encodeURIComponent(currentPageUrl), 1);
setTimeout(() => {
const isMobileDevice = window.matchMedia('(max-width: 768px)').matches;
if (isMobileDevice) {
window.location.href = 'https://test-play.softr.app/tab-features-only';
} else {
window.location.href = 'https://test-play.softr.app/tabs-for-softr-with-var-iterator-js-snippet';
}
}, 100);
function _setCookie(name, value, days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "expires=" + date.toUTCString();
document.cookie = name + "=" + value + ";" + expires + ";path=/;" + 'SameSite=Lax; Secure';
}
});
</script>
As a reference, all about redirection after signin (or signup) => Complete guide: Redirect users to the page they were before signing up/signing in + onboarding use case