Simple Membership Plugin › Forums › Simple Membership Plugin › Login re-directs to homepage, need to just refresh current
- This topic has 12 replies, 4 voices, and was last updated 8 years, 8 months ago by
nmac.
-
AuthorPosts
-
September 3, 2016 at 3:05 pm #8116
tombyrom
ParticipantHi,
So on my page templates, archives, taxonomies and single posts I use this to check whether the member is logged in<?php if (SwpmMemberUtils::is_member_logged_in()) : // Check if logged in ?>Then if they are I show the content if not I show the:
<?php wp_login_form(); ?>Once they have put in there login info and press login it re-directs to the homepage, which is obviously quite annoying it should just display the content they were trying to access.
I have tried your login add on but don’t think that will work in this instance, I haven’t set any re-direct at member level either…
Anyway I can get this sorted?
PS. I have used your own login shortcode as well and it does the same thing
September 3, 2016 at 11:50 pm #8122mbrsolution
ModeratorHi, do you have the latest version of Simple Membership installed? Do you also have the following add-on installed?
September 4, 2016 at 8:10 am #8132tombyrom
ParticipantHi,
Yes latest version running. I had tried that plugin, sorry that was what I was referring too but it wont work and it doesn’t because in the documentation it says:When this feature is enabled, if you click on the “Login” link of a protected post or page, it will send you to the login page with “swpm_redirect_to” query parameter in the URL (meaning this feature is active).
The way I’m set up if they try to access a page that only members can see then it checks whether they are logged in and if they aren’t it doesn’t show the content it shows a login form and subscribe form instead, on the same page; so they don’t click through to another page to login meaning the query parameter is not added to that URL.
Obviously the way I am doing it is much cleaner everything happens on page instead of going through to another page to be redirected back.
But after they login it goes to the homepage I just need them to stay on the current page or at least just refresh the current page as they will then be logged in and the page will see they are logged in and display the content.
Many thanks
TomSeptember 4, 2016 at 10:09 am #8139mbrsolution
ModeratorHi, try the following miscellaneous link. There might be a code in this page that might help you with your question.
Regards
September 4, 2016 at 1:02 pm #8143tombyrom
ParticipantI had already checked this page, nothing in it helps in my situation. Any other ideas?
What code would I need to add the swpm_redirect_to query parameter to my own link so it redirects to the current/last page?
Just found out as well that using the normal way of protecting posts/pages doesn’t seem to work with custom page templates?
Is this correct? As it only works on default page templates any I have created its doesn’t stop people from accessing them…even when its check to protect them.
Thanks
September 4, 2016 at 1:22 pm #8146tombyrom
ParticipantOk so I’ve managed to get my work around working using this:
<a href="http://mysite.co.uk/membership-login/?swpm_redirect_to=<?php echo get_permalink( $post->ID ); ?>">Log in</a>So I will now show a log in link and then redirect back to the page I was trying to access.
The reason I have hard coded everything in is because we only have one membership level and there will be lots of different custom posts, this way I protect everything including archives, taxonomies, single post, pages. Just makes life easier… and means the client doesn’t have to remember to protect everything they upload. It’s all automated
September 5, 2016 at 8:36 am #8148mbrsolution
ModeratorHi, thank you for sharing your solution. I am sure it will come in handy for anyone trying to achieve a similar setup as yours.
Kind regards
September 17, 2016 at 9:00 pm #8346dimabuko
ParticipantHello!
Seems that for me it will be the great solution too (I talk about code:
<a href="http://mysite.co.uk/membership-login/?swpm_redirect_to=<?php echo get_permalink( $post->ID ); ?>">Log in</a>But I need some help. Now my Log In link displays in such cases and it is included in php code too, something like this:
... esle { echo('<a href="http://mysite.co.uk/membership-login/">Log in</a>'); }So how I can add <?php echo get_permalink( $post->ID ); ?> inside href?
September 18, 2016 at 8:52 am #8353dimabuko
ParticipantI did it finally like this.
$whereiam = get_permalink( $post->ID ); echo('<a>' . $whereiam . '">Log in</a>');September 18, 2016 at 8:55 am #8355dimabuko
ParticipantBut also I have a problem now. In case when user click this link on Registration page. He actually did it first time, after his registration. So he is redirected to registration page. Don’t know how to fix it.
September 18, 2016 at 9:15 am #8357dimabuko
ParticipantIs there possibility to redirect user after successful registration (free) to the main page?
I found that there is feature Thank you page for Non-free membership (https://simple-membership-plugin.com/paid-registration-from-the-thank-you-page/). And is it possible for free?September 18, 2016 at 10:43 am #8359dimabuko
ParticipantI found the way to fix my problem with that action hook:
add_action('swpm_front_end_registration_complete', 'after_registration_callback'); function after_registration_callback ($member_info) { $redirect_url = '/registered/'; wp_redirect($redirect_url); exit; }September 7, 2017 at 2:14 pm #11908nmac
ParticipantI’m having the same problem.
For a post that has full protection the redirect works with login on that page.
BUT none of my posts have full protection.With a login on the custom message (partial protection) it either jumps to the main page or hangs up on the member login page. SAME issue with the sidebar login widget.
I tried to implement this above code and no matter what I do it’s not working.
<a href="http://mysite.com/membership-login/?swpm_redirect_to=<?php echo get_permalink($post->ID )>">Log in</a>Is there some sort of documentation for “swpm_redirect_to” usage?
-
AuthorPosts
- You must be logged in to reply to this topic.