Viewing 21 posts - 1 through 21 (of 21 total)
  • Author
    Posts
  • #1000254

    Hi, as I have restricted content for logged in users I encountered the problem that private posts are not shown to users when their categories are assigned to e.g. “magazine” or “masonry”. But this is vital for my intranet-plans.
    Private posts and pages are shown when posted individually but not when used in Enfold’s “design-elements”.
    I guess this is a known problem but any help or code snipped for functions.php or the like are highly appreciated.
    I have installed a dev-installation and will provide the link as private content.

    #1000359

    Hey jobalzer,

    Can you give us temporary admin access to your website in the private content box below, so that we can have a closer look?

    Are you using some plugin to restrict access?

    Best regards,
    Victoria

    #1000468
    This reply has been marked as private.
    #1000644

    Any tipps how I can proceed?

    #1000954

    Hi,

    That seems to be an issue with the plugin you are using to lock things down, have you tried to contact the plugin developer?

    Best regards,
    Basilis

    #1001624

    No, it has nothing to do with the Plugin. But do you recommend another way to let private content be shown in magazine or masonry in order to restrict content to user roles and which works with enfold?

    #1001820

    Hi,

    You can use this code to include private posts in magazine and masonry elements:

    
    
    add_filter('avia_masonry_entries_query', 'avia_custom_query_extension', 10, 2);
    add_filter('avf_magazine_entries_query', 'avia_custom_query_extension', 10, 2);
    add_filter('avia_blog_post_query', 'avia_custom_query_extension', 10, 2);
    
    function avia_custom_query_extension( $query, $params ) 
    {
    	$query['post_status'] = array('publish','private');
    	return $query;
    }
    

    Please add this code to the child theme functions.php. If necessary you can also add another post status to the query (i.e. draft or pending, see https://codex.wordpress.org/Class_Reference/WP_Query#Status_Parameters for more information).

    Best regards,
    Dude

    #1001833

    Tx, will try!

    #1001836

    Hi,

    Ok, I’ll leave this thread open :)

    Best regards,
    Dude

    #1003269

    Sorry for the delay.

    The functions.php-code does not work.
    Please have a look at the WP-installation I mentioned above. The standard-WP-blog is showing all entries, but the magazine and the masonry don’t.

    I entered the functions.php-code you gave me via Design -> Editor -> functions.php

    Please have a look and feel free to change things, it’s only a system for testing purposes.

    Thanks in advance!

    #1003722

    Hi,

    I fixed it now. Tbh I don’t think this is a theme bug however I found the culprit. We use the get_terms() function which excludes empty categories (categories without assigned posts) by default. WordPress does not count private posts to the total number of assigned posts of a category. Because there were no other posts assigned to the “private posts” category wordpress excludes this category from the get_terms() query and the side effect was that our magazine and masonry template didn’t show this category.

    I added

    
    array('hide_empty'=>true)
    

    to all occurrences of get_terms() in config-templatebuilder/avia-shortcodes/av-helper-masonry.php and config-templatebuilder/avia-shortcodes/magazine/magazine.php. We’ll probably include another filter with the next update which will enable you to set the hide_empty value to true.

    Kind regards,
    Dude

    #1003808

    Thanks for helping but now it shows the posts even to not-logged-in visitors so public, but the private posts should only be seen by logged-in users.

    Kind regards,
    jobalzer

    #1003949

    Hey!

    Sry I thought you want to show private posts to all users. You can use this code instead to show posts only to logged in users:

    
    
    add_filter('avia_masonry_entries_query', 'avia_custom_query_extension', 10, 2);
    add_filter('avf_magazine_entries_query', 'avia_custom_query_extension', 10, 2);
    add_filter('avia_blog_post_query', 'avia_custom_query_extension', 10, 2);
    
    function avia_custom_query_extension( $query, $params ) 
    {
    	if(is_user_logged_in()) $query['post_status'] = array('publish','private');
    	return $query;
    }
    

    Cheers!
    Peter

    #1003983

    Hi Dude,
    thanks for your help. But still it does not work satisfiying.
    When logged out everything seems to work perfectly. When logged in private posts are missing.

    Would you please have a look on the page?
    Thanks.
    (The only element that works flawlessly in any case is the WP-standard-blog – last element on the page. So it actually might be an enfold-issue which I urgently would need to get fixed.)

    • This reply was modified 6 years, 3 months ago by jobalzer. Reason: forgot to mention the working wp-standard-blog
    #1003993

    Hey!

    Please check it again – it should work now.

    Best regards,
    Peter

    #1004011

    Thanks, it seems to work now.
    Can you pls tell me what you did, so I can apply the fix to my main site and current project?

    #1004297

    Hey!

    I replaced the code I gave you before with this one:

    
    add_filter('avia_masonry_entries_query', 'avia_custom_query_extension', 10, 2);
    add_filter('avf_magazine_entries_query', 'avia_custom_query_extension', 10, 2);
    add_filter('avia_blog_post_query', 'avia_custom_query_extension', 10, 2);
    
    function avia_custom_query_extension( $query, $params ) 
    {
    	if(is_user_logged_in()) $query['post_status'] = array('publish','private');
    	return $query;
    }
    

    Cheers!
    Peter

    #1009427

    Thanks, Peter!

    I still encouter related problems with this in my main-installation e.g. with the tag-cloud.
    So perhaps you could leave this open for some days more while I create a new thread for the other problem.

    Thanks for your help again.

    #1009435

    Hi,

    I’ll leave it open. Please note the tag cloud widget is a standard wordpress widget and it’s probably no theme issue (if you search for “tag cloud private posts” you’ll find useful information).

    Best regards,
    Peter

    #1009436

    Hi Peter,
    perhaps you could jump over to the thread I opened because you are already comfortable with the installation we used to solve our problem?

    #1009443

    Hi,
    I answered there.

    Best regards,
    Peter

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