Quick background:
We have two groups of users, Nannies and Families.
Before the snippet, the users created themselves via a Toolset User Form, and depending on which link they chose, a different role is assigned.
User clicks Sign Up: User Form - New Family (1308) is activated and user is assigned role of Unverified Family.
User clicks Become a Native Nanny: User Form - New Native Nanny (1242) is activated and user is assigned role of Unverified Nanny.
After the completion of the simple user form (First Name, Last Name, Email and Password), the users are required to log in so that they can fill out their details and hence create a post in either the Post Type Families or the Post Type Nannies respectively.
If a user breaks off the sign-in process at any time and has to come back to it at any point, they just log in again, and they are redirected correctly to the appropriate page. Only when the login is automatic they are not redirected to the correct page.
I suspect this could be a conflict somehow with the existing Custom Code Snippet "conditional-redirect-on-successful-login" and think perhaps some tiny tweak in the code might be necessary. Could it be something to do with the order in which the code snippets are being executed maybe?
Feel free to reproduce the 404 error by clicking Sign Up or Become a Native Nanny links in the menu.
We'd appreciate your expert assistance as always to get this working smoothly as it would be a HUGE boost in streamlining our sign-up process.
The code you have to automatically login users that complete the registration form uses the wp_signon function. That is not part of the normal login process, and the login_redirect filter never gets triggered, which is why that code doesn't run.
I think you should just be able to set up the redirection you want in the form settings (the redirection happens after the form submission has completed, i.e. after the auto login code you trigger using the cred_save_data hook).
It looks at the moment like you redirect users to the login page, but if they are already logged in (because you auto log them in) that's not where they should be redirected to.
Try changing the form settings to where you want the logged-in new users to go.
I changed the User Form - New Family User (1308) to go to page "Sign Up - Complete Profile" instead. But now the autologin doesn't work and I get a 404.