Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #457083

    Hi,
    we are trying to redefine the Homepage for logged-in users through a script in functions.php like
    https://wordpress.org/support/topic/different-static-front-page-for-logged-in-and-logged-out-users

    With Enfold this seems not to work as Enfold has its own way to define “home”.

    How can we achieve our idea with Enfold?
    Tx,
    Frank

    #458876

    Hi Frank!

    Paste this in child theme functions.php:

    if(!function_exists('avia_modify_front'))
    {
    	/**
    	*
    	* This function checks what to display on the frontpage
    	* Its a new and much simpler function to redirect front and blog pages, by simply filtering the settings->readings options and replacing them with the avia theme options
    	*/
    
    	add_action('init', 'avia_modify_front', 10);
    	function avia_modify_front($wp_query)
    	{
    		if(!is_admin())
    		{
    			if(avia_get_option('frontpage'))
    			{
    				add_filter('pre_option_show_on_front', 'avia_show_on_front_filter');
    				add_filter('pre_option_page_on_front', 'avia_page_on_front_filter');
    				
    				if(avia_get_option('blogpage'))
    				{
    					add_filter('pre_option_page_for_posts', 'avia_page_for_posts_filter');
    				}
    			}
    		}
    	}
    
    	function avia_show_on_front_filter($val) { return 'page'; }
    	function avia_page_on_front_filter($val) { return is_user_logged_in() ? avia_get_option('frontpage') : 254; }
    	function avia_page_for_posts_filter($val){ return avia_get_option('blog_style') !== 'custom' ? avia_get_option('blogpage') : ""; } //use the layout editor to build a blog?
    }

    Modify this part (change 254 by the Page ID you want to show to not logged-in users):

    function avia_page_on_front_filter($val) { return is_user_logged_in() ? avia_get_option('frontpage') : 254; }
    

    Regards,
    Josue

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.