kylephillips / favorites

Simple and flexible favorite buttons for any WordPress post type.
https://favoriteposts.com
223 stars 86 forks source link

Allow private posts in user favorite lists #140

Open nighswon opened 4 years ago

nighswon commented 4 years ago

It looks like at one point a bug was fixed to avoid unpublished posts from showing in the favorites list. This is great for drafts and whatnot, however, there's an argument to allow private posts.

I have a membership site with private content and I wanted to let users bookmark their favorites however a lot of the content is private content.

I just went ahead and edited the private function to allow this for my site, and made a note that for future updates I'll have to do the same, but just wanted to run this by you as a potential long-term feature.


    {
        $allowed_statuses = ( isset($this->filters['status']) && is_array($this->filters['status']) ) ? $this->filters['status'] : array('publish','private');
        $status = get_post_status($id);
        if ( !$status ) return false;
        if ( !in_array($status, $allowed_statuses) ) return false;
        return true;
    }```
brianjohnpenner commented 4 years ago

I need this as well on a site I have this plugin on.

daniilicic commented 3 months ago

@nighswon probably a long shot asking this here, 4 years later, but still, worth the shot :)

Where did you place that function to add private posts to the list?

I am experiencing the same issue (all my posts are privately published because of the membership access) and I need the private posts to be seen on the list which is shown when using [user_favorite] shortcode.

EDIT: I managed to find the line of code @nighswon modified, for anyone else, it's the 113 line of the /favorites/app/Entities/User/UserFavorites.php file.

nighswon commented 3 months ago

Awesome! Was just coming in here to mention that. Hopefully that still works. We haven't used this one in a while.