Replace the WP login/registration page
2016-01-06 at 22:03 #554
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.2016-01-08 at 10:38 #558Krum CheshmedjievParticipant
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.2016-01-08 at 10:56 #560
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?2016-01-08 at 16:35 #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.”2016-01-08 at 16:51 #564
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?2016-01-08 at 19:54 #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/"); ?>2016-01-08 at 20:20 #571
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?2016-01-09 at 00:17 #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.server2016-01-09 at 10:31 #577
I see. I guess i’ll have to study this, unless someone can suggest the actual code to use.
Thanks.2016-01-09 at 11:15 #579Krum CheshmedjievParticipant
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.
2016-01-09 at 11:23 #580
- This reply was modified 7 years ago by Cristián Lávaque. Reason: Fix tiny syntax error in code
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.
- This reply was modified 7 years ago by Carole Asselin.
- You must be logged in to reply to this topic.