Replace the WP login/registration page

Forums General Replace the WP login/registration page

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #554
    Carole Asselin
    Participant

    I feel like i am playing with Lego blocks as i have the impression i know all the pieces of the puzzle, but can’t put them together. Here is my challenge.

    On my site, i have some custom code on the header that allow people to login or register, and to welcome them or logout. You can see that, for example, on top of the main page: http://scrapbookcampus.com

    The custom code for it is this:

    [s2If is_user_logged_in()] 
    <span style="font-size:10pt;">Welcome [s2Get constant="S2MEMBER_CURRENT_USER_DISPLAY_NAME" /] / <a href="/my-account/">My Account</a> / <a>" title="Log out">Log out</a></span>
    [/s2If]
    [s2If !is_user_logged_in()] 
    <span style="font-size:10pt;">
    <a>" title="Login">Login</a>
    </span>  
    <span style="font-size:10pt;">
    <a href="http://scrapbookcampus.com/wp-login.php?action=register">Register</a> </span>
    [/s2If]
    

    Initially, i am pretty sure it was redirecting the user to the same page they were when they clicked the link but now it is not working, so i am not sure anymore if it was 100% doing that, or if there was an update to WP or s2M that makes it NOT work that way anymore, but in any case, i need a slightly different route now.

    I need the user to be able to either login OR register but instead of going through the WP login/registration page, to go through the FREE registration form (so i can add a ccap) BUT also return to the exact page they were on when they clicked (so i can’t use the success attribute, unless i can get it to pull the initial URL of the page the user was on).

    I basically want the same functionalities as the s2M pro login widget and the FREE registration form.

    Is that possible? It seems like all the pieces are available in s2M, but i can’t piece them together.

    #558
    Krum Cheshmedjiev
    Participant

    The link should be at the “Login” word inside “span”, but forum poster seems deletes it. The link is what takes the member back to the page he was before to log in.

    #560
    Carole Asselin
    Participant

    This works but it uses the WP login page, and i can’t get a ccap on the WP login page.
    Can you suggest something?

    #562

    go through the FREE registration form (so i can add a ccap) BUT also return to the exact page they were on when they clicked (so i can’t use the success attribute, unless i can get it to pull the initial URL of the page the user was on).

    So what you want is bring the user back to the page he clicked the registration link from after creating his account?

    After registration he needs to login, so he can’t be redirected there right after registration. You want the first login to bring him to the page he clicked the registration link from?

    Maybe the registration link could just open the free registration pro-form in another tab/window, and leave the current one open and open a message that instructs him to “please reload this page after completing your registration and logging in.”

    #564
    Carole Asselin
    Participant

    Maybe the registration link could just open the free registration pro-form in another tab/window, and leave the current one open and open a message that instructs him to “please reload this page after completing your registration and logging in.”

    Yeah, i can try that.
    Since the Pro login has something in it redirecting the user back to the same page, is there a way to use that feature/code?

    #569

    For a login from the same page he’ll be taken back to, yes. The login widget would need to be on the same page he’ll be taken back to, and the widget configured to redirect the person to the “previous” (i.e. the one where the widget is when he uses it) page after login.

    If you start the login from another place and want the person to end in a particular URL, there are a couple of ways:

    If you link to wp-login.php, you’d do http://example.com/wp-login.php?redirect_to=/the-page-you-want-him-taken-to/ and after logging in he’ll be taken to the redirect_to address.

    If you’re using the s2 Pro login widget via PHP, see: http://www.s2member.com/codex/stable/s2member/api_functions/package-functions/#src_doc_s2member_pro_login_widget()

    <?php s2member_pro_login_widget("login_redirect" => "http://example.com/the-page-you-want-him-taken-to/"); ?>
    
    #571
    Carole Asselin
    Participant

    I don’t want the user to come back to a specific page. I wish they would come back to the “original” page. Is there a way to extract the url of the original page to redirect dynamically back to where they were?

    #575

    Yes, that’s what I meant. That was just an example to show how to achieve the redirection, but then you’d need to customize it to change the URL dynamically.

    You could probably use the $_SERVER variable to get the address of the page he’s on. http://php.net/reserved.variables.server

    #577
    Carole Asselin
    Participant

    I see. I guess i’ll have to study this, unless someone can suggest the actual code to use.
    Thanks.

    #579
    Krum Cheshmedjiev
    Participant

    The code:
    http://example.com/wp-login.php?redirect_to=<?php echo $_SERVER['REQUEST_URI']; ?>

    Needs PHP to run at this time, you may need to use a “PHP in posts/pages/widgets” plugin.

    • This reply was modified 8 years ago by Cristián Lávaque. Reason: Fix tiny syntax error in code
    #580
    Carole Asselin
    Participant

    Thanks Krum. This is for the LOGIN, right? the LOGIN is what i am using on the top right of pages on my site, correct?
    Would it work for the REGISTER too?

    I am trying to put it in the initial code i have but not sure if i can use something similar for the Register part.

    On the other hand, would that be using the free registration for s2M or the default WP one? Since i would like to get a “default” ccap, i could put one for the free membership form, but not on the WP form.

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.