Home › Forums › Calendar Products › Community Events › Reroute list/edit page when not logged in
- This topic has 5 replies, 2 voices, and was last updated 10 years, 1 month ago by
George.
-
AuthorPosts
-
February 26, 2016 at 2:47 pm #1082749
clarity
ParticipantI was given this code to re-route a user who is not logged in from adding an event:
<?php add_action( 'tribe_ce_event_submission_login_form', 'redirect_to_better_login_page' ); function redirect_to_better_login_page() { if ( ! is_user_logged_in() ) { wp_safe_redirect( 'http://avindustrycalendar.com/login-register/' ); die(); } } ?>It works great. Now, is there a way to do the same for the /events/community/list page as well?
When a user is not logged in and the go to the /events/community/list page, they get routed to a generic login page. We want them to go to our registration page.
Thanks
February 26, 2016 at 4:05 pm #1082766George
ParticipantHey @clarity,
If you are trying to redirect to the same URL, http://avindustrycalendar.com/login-register/, then you should be able to have the same redirection happening by using the callback function for just another action; an action on the List View page.
So, adding this line of code to your theme’s functions.php file should do the trick:
add_action( 'tribe_ce_before_event_list_top_buttons', 'redirect_to_better_login_page' );Cheers,
GeorgeFebruary 26, 2016 at 7:11 pm #1082809clarity
ParticipantGeorge,
I tried… nothing I did worked…
<?php add_action( 'tribe_ce_before_event_list_top_buttons', 'redirect_to_better_login_page' ); add_action( 'tribe_ce_event_submission_login_form', 'redirect_to_better_login_page' ); function redirect_to_better_login_page() { if ( ! is_user_logged_in() ) { wp_safe_redirect( 'http://avindustrycalendar.com/login-register/' ); die(); } } ?>I also tried:
<?php add_action( 'tribe_ce_event_submission_login_form', 'redirect_to_better_login_page' ); function redirect_to_better_login_page() { if ( ! is_user_logged_in() ) { wp_safe_redirect( 'http://avindustrycalendar.com/login-register/' ); die(); } } add_action( 'tribe_ce_before_event_list_top_buttons', 'redirect_to_better_login_page' ); function redirect_to_better_login_page() { if ( ! is_user_logged_in() ) { wp_safe_redirect( 'http://avindustrycalendar.com/login-register/' ); die(); } } ?>Both resulted in errors
-
This reply was modified 10 years, 1 month ago by
clarity.
February 27, 2016 at 6:08 pm #1083025George
ParticipantHi @Clarity,
You can try this code instead:
add_action( 'login_form_top', 'redirect_to_better_login_page' );Do not define the redirect_to_better_login_page() function more than one time.
Also, ensure that your links end up like this:
'http://avindustrycalendar.com/login-register/'
Not like this:
'http://avindustrycalendar.com/login-register/O39;
The closing PHP tag is also not required and I would recommend removing it.
— George
March 6, 2016 at 4:45 pm #1085729clarity
ParticipantThis is perfect. It worked great. Thank you.
It seems that the previous functions.php file had an issue, for some reason. Don’t know why, but finally creating a new file worked.
-
This reply was modified 10 years, 1 month ago by
clarity.
March 7, 2016 at 2:18 pm #1086006George
ParticipantGlad to hear it! Best of luck with your site. 🙂
Thanks,
George -
This reply was modified 10 years, 1 month ago by
-
AuthorPosts
- The topic ‘Reroute list/edit page when not logged in’ is closed to new replies.
