• Madyson

    (@madyonhope1998)


    When someone visits the website and clicks on something such as the resources page containing videos and realizes they haven’t logged in or signed up. Once they have signed up or logged in instead of being directed to the home page, can they be taken back to the page they were previously on? If so how can this be done? I am not a developer so was hoping for a simple solution to this or for someone to guide me through a process allowing for this to happen.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Madyson

    (@madyonhope1998)

    Moderator bcworkz

    (@bcworkz)

    How this is accomplished is conceptually simple, but code tweaks are required in several places to pull this off. The code that actually does the registration can redirect to anywhere once the registration is successful, provided nothing has yet been output and that the code knows where to go. This is done with wp_redirect().

    One way for code to know where to redirect to is to include a hidden field in the form that contains the final destination. For this to happen, the code that creates the form’s hidden field needs to know what that destination is. This could be accomplished by having all links to the registration page include an URL parameter that has the current page URL. So the href in the registration link might look like this:
    inhouserecruitment.com/register/?redirect=current-page-slug

    The registration form code can then get the destination with $_GET['redirect'] and include that value in a hidden form field. If the form field’s name is also ‘redirect’, then the registration code can get the destination with $_POST['redirect'] for use in wp_redirect() once the registration is successful.

    You can see how the original page’s slug is passed along in each step so the correct redirect can occur. Simple enough, but getting this to happen by altering the existing code could be tricky. It depends on how the current code is implemented. One could certainly directly hack the code to meet our needs, but then our changes could be lost when the theme or plugin is updated. The challenge is to do this in a manner such that theme or plugin updates leave our code unchanged.

    Thread Starter Madyson

    (@madyonhope1998)

    Is there any chance of you walking me through the process of doing this redirect as I am not sure on how to do this and create the redirect? Also the Join page was created using a theme does this change anything?

    Moderator bcworkz

    (@bcworkz)

    Sorry, I’m afraid I cannot be much help. It is because your KLEO theme is not open source, so I cannot see the source code for myself. If this theme is one of those installed as a child of a common framework, your options are further restricted because you cannot create a child of a child. Child themes are usually a good way to protect hacks like you are contemplating from being overwritten by theme updates. By taking up the child position, your theme’s authors have taken this option away from you.

    It may be possible to override the theme from a plugin, but I could not say how that might be possible without access to source code. It’s certainly possible to directly hack the theme code, but then the hacks will be lost when the theme is updated.

    I regret that I cannot help you further.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Join Page Redirect’ is closed to new replies.