- This topic has 27 replies, 2 voices, and was last updated 9 years, 4 months ago by Syam Mohan.
-
AuthorPosts
-
August 6, 2015 at 9:33 am #13954BrattParticipant
Hi!
Thanks for a wonderful plug-in that makes my page so much easier to handle!
I wonder if it’s possible to auto redirect to the role’s login redirect url, when landing on the startpage, otherwise redirect to wordpress login page.
I have a startpage that use a custom template called page-login.php.
August 6, 2015 at 6:24 pm #13981Syam MohanKeymasterHi Bratt,
Not possible using the plugin right now. But I could give you some code to add to your page template if you are comfortable with it.
Thanks
Syam
August 7, 2015 at 3:28 am #14008BrattParticipantWow great, absolutly! 🙂
August 7, 2015 at 9:02 am #14028Syam MohanKeymasterif(is_user_logged_in())
wp_redirect(apply_filters(‘login_redirect’, ‘/’));
else
wp_redirect(‘/wp-login.php’);I did not test the code, just wrote it here. Let me know if it doesn’t work.
Thanks
Syam
August 7, 2015 at 5:07 pm #14048BrattParticipantIt didn’t work 100%, it works as long as your not logged in, but if logged in it will not redirect to “login redirect” url. =(
Any spontaneous ides ?, really appreciate the help =)
August 7, 2015 at 5:40 pm #14054Syam MohanKeymasterWhen is this code executing?
August 9, 2015 at 1:34 am #14087BrattParticipant<?php if(is_user_logged_in()) wp_redirect(apply_filters(‘login_redirect’, ‘/’)); else wp_redirect(‘/wp-login.php’); ?> <?php get_header(); ?> <div id="primary" class="row-fluid"> <div id="content" role="main" class="span8 offset2"> <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <article class="post"> <h1 class="title"><img class="img-responsive aligncenter title" alt="DSV" src="http://xxxxxxxx.xxx/xxx_b.png"><?php the_title(); ?></h1> <div class="the-content"> <?php the_content(); ?> <?php wp_link_pages(); ?> </div><!-- the-content --> </article> <?php endwhile; ?> <?php else : ?> <article class="post error"> <h1 class="404">Här var det tomt.</h1> </article> <?php endif; ?> </div><!-- #content .site-content --> </div><!-- #primary .content-area --> <?php get_footer(); ?>
August 9, 2015 at 1:00 pm #14096Syam MohanKeymasterThe code I sent you can only be executed after the plugins have been loaded. Otherwise it won’t work, since the login redirect settings comes from a plugin. Can you try to execute it in the ‘plugins_loaded’ action?
Thanks
August 9, 2015 at 2:20 pm #14103BrattParticipantSorry, i didn’t think i got this. 🙁
I tried to add this instead but didn’t work at all.
<?php add_action( 'plugins_loaded', 'my_plugin_override' ); function my_plugin_override() { if(is_user_logged_in()) wp_redirect(apply_filters(‘login_redirect’, ‘/’)); else wp_redirect(‘/wp-login.php’); } ?>
August 9, 2015 at 8:44 pm #14122Syam MohanKeymasterIs it possible for you to give me access to your site?
Thanks
August 9, 2015 at 11:46 pm #14131BrattParticipantThis reply has been marked as private.August 10, 2015 at 8:40 am #14150Syam MohanKeymasterCan you also send me the location of your template file and the url/page I need to access to test it?
Thanks
August 10, 2015 at 10:37 am #14153BrattParticipantThis reply has been marked as private.August 10, 2015 at 6:30 pm #14175Syam MohanKeymasterHi Bratt,
I was able to connect successfully. But the changes I make within the PHP code takes lot of time to reflect on the web page. Either you have a caching plugin or your PHP opcache re-validation frequency is low. I didn’t try with deactivating the plugins, if in case this is a live site.
Thanks
syam
August 11, 2015 at 12:25 am #14188BrattParticipantI deactivated Wordfence, should be the only plugin that should have some with the cache to do. I will try it as soon as i can 🙂
So glad you are helping me with this!
-
AuthorPosts
- The topic ‘If logged in redirect to Login Redirect url?’ is closed to new replies.