Adding Login Welcome Page to Navigation Menu

Hello,

I have looked all through your forums and it seems this issue has come up several times but I have yet to find a clear resolution. Please advise on the best way to address this issue.

I have everything working the way I want it to on my site. When a user logs in I have them being correctly routed to their individual user login pages. However, once they leave the welcome page there is no easy way for them to return to that page once they leave it. I would like to have a link in the navigation that will go back to that page. I need to be able to have a page in the main navigation that uses the data from the %%current_user_nicename%% variable. If you could please explain or point me in the direction of the best way to do that I would really appreciate it. Thanks!

Take a look at this: https://s2member.com/kb-article/customizing-your-login-welcome-page/

Thanks for responding. I have looked all through that stuff and am not having a problem routing a user to their own page. I am unable to figure out how to make a button in the main navigation to call up a users page based on
their user name. If I am somehow missing that being covered in that doc I apologize. If you have any ideas on how to accomplish this I would greatly appreciate it.

That article also shows you how to construct a URL. So the simplest approach would be just to paste the URL with the variable into the menu using the custom links box.

That was the first thing I tried. Using the %%current_user_nicename%% variable in a custom url just returns an error.

OK. When asking for help, you should also say exactly what you’ve tried. It saves a lot of time!

Have you tried writing the variable in a a custom PHP function? If it gets parsed then, you could simply add a link to the Login Welcome Page in the menu, and then write a function that redirects whomever needs to be redirected.

Sorry about that. No I haven’t unfortunately I am a designer primarily and not much of a php coder. I have been looking into some regular wordpress related articles on how to dynamically change a page name based on a variable but thus far haven’t found anything I can understand well enough to make it work. Seems like this is something that would be a very common issue. The plugin is very cool and doing 95% of what I want it to, but the client won’t be happy and sign off on this site until I have this issue resolved.

OK. I don’t use that particular aspect of s2Member myself, but I can think of a future use-case where I might find it useful. So post the URL(s) you are looking at here, and I’ll see if I can work out what you need.

Actually, thinking about this a little more, I wonder whether the LWP’s shortcode will do the trick. In other words, try using this: [s2Get constant="S2MEMBER_LOGIN_WELCOME_PAGE_URL" /]

Sorry use that where exactly? In the custom url field for the menu item?

No, forget that. It will just set up from where the members need to be redirected. So it will only do half the job.

yeah that just returns a completely blank page: about:blank

I will try and find the other pages where people are having this issue and see if you can make sense of the responses in those messages. by the way I really appreciate your time and willingness to help

OK, so you haven’t actually created a Login Welcome Page at all then. What do your special redirection URLs look like?

I have created a login welcome page and its all working perfectly. When a user logs in they see everything come up exactly how I want it do. Howerver once they go to a different page there is no user friendly way to return to that landing page.

What I am trying to do is have a l;ink in the menu called Summary and then they click that it takes them to the login welcome page.

does that make sense?

The destination of the link in menu needs to change dynamically based on the user name.

1 Like

But you haven’t created a static LWP at all?

I do have a static page called “My Login Welcome Page” as requested in the docs.

Oh, good. In that case, could you try adding this code as an mu-plugin (or, without the opening PHP tag, in your child theme’s functions.php file):

<?php
function kts_redirect_to_special_redirection_lwp() {	
	if ( !is_page( S2MEMBER_LOGIN_WELCOME_PAGE_ID ) ) {
		return; // nothing to do if no initial attempt to go to Login Welcome Page
	}
	$current_user = wp_get_current_user();
	$username = $current_user->user_login;

	if ( current_user_is( 's2member_level1' ) ) { // must match user role		
		$page = get_page_by_path( $username, OBJECT, 'page' );
		if ( isset( $page ) ) {
			$redirect = get_permalink( $page );
			wp_redirect( $redirect ); // perform the redirection
			exit;
		}
	}
}
add_action( 'template_redirect', 'kts_redirect_to_special_redirection_lwp' );

Then add the static LWP to your menu.