- This topic has 8 replies, 3 voices, and was last updated 4 months, 2 weeks ago by
Leo.
-
AuthorPosts
-
September 2, 2020 at 7:27 am #1427809
John
Hi!
I’m looking for a way to show different home-page/front-page content for a logged-in user/member. Ideas?
Thanks!
John
September 2, 2020 at 7:48 am #1427835John
I tried this in snippets but it didn’t work for me.
if( is_user_logged_in() ) { $page = get_page_by_title( 'page-title'); update_option( 'page_on_front', $page->ID ); update_option( 'show_on_front', 'page' ); } else { $page = get_page_by_title( 'page-title' ); update_option( 'page_on_front', $page->ID ); update_option( 'show_on_front', 'page' ); }
September 2, 2020 at 7:58 am #1427986David
StaffCustomer SupportHi there,
this topic may help:
https://generatepress.com/forums/topic/redirect-logged-in-users/#post-1298931
If you read further down Tom also provides a Stack Overflow for redirection upon login.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 2, 2020 at 8:58 am #1428073John
Thanks, David.
I’m ok with redirecting users after login, what I’m trying to do is this;
-
If a user is logged out and goes to the home page url, they see page A.
If a user is logged in and goes to the home page url, they see page B.I tried using the following code mentioned by someone else in the thread you referenced (found here, with different page id’s) but when activated it changes the static and post pages in DASHBOARD > SETTINGS > READING to the same page. That fouls things up pretty good.
?php function switch_homepage() { if ( is_user_logged_in() ) { $page = 2516; // for logged in users update_option( 'page_on_front', $page ); update_option( 'show_on_front', 'page' ); } else { $page = 2; // for logged out users update_option( 'page_on_front', $page ); update_option( 'show_on_front', 'page' ); } } add_action( 'init', 'switch_homepage' ); ?>
September 2, 2020 at 9:25 am #1428110Leo
StaffCustomer SupportI would recommend starting a topic on WordPress Stack if the link David provided doesn’t solve the issue:
https://wordpress.stackexchange.com/This isn’t a GP related question so we can only provide limited help here.
Thanks for your understanding π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 2, 2020 at 9:35 am #1428117John
Will do. Thanks, Leo.
September 2, 2020 at 9:39 am #1428120Leo
StaffCustomer SupportNo problem π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 2, 2020 at 10:58 am #1428185John
On the off chance that someone else has this same question, here is a link on StackExchange that addresses this issue.
September 2, 2020 at 11:18 am #1428213Leo
StaffCustomer SupportAwesome.
Thanks for sharing!
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.