• Resolved Jandal

    (@jandal)


    Great plugin going here.

    I’m having issues with the following setting.

    Posts Page Settings > Posts page includes excerpts of content viewable only by members

    When this option is checked, and a non-logged in user browses the site, it breaks the site. It works fine for logged in users.

    I have not had a chance to personally look into why. If I make any progress before anyone else I will let you know.

    Thanks,
    =-)

Viewing 15 replies - 1 through 15 (of 19 total)
  • Thread Starter Jandal

    (@jandal)

    UPDATE:
    The problem appears to be happening in file
    /member-access/lib/MemberAccess.php

    In the function
    function filterContent($content)

    And there are 2 issues;
    a) If the post does NOT have an “excerpt” then the plugin breaks the site.

    b) If 1 post is marked as “private” then the function will pull the excerpts for all of the posts on the page. My understanding of how I thought it would work, is that it would only pull the excerpt for the private page only?

    I will continue working on it and let you know if I can resolve either of the issues.

    Thanks,
    James
    =-)

    Thread Starter Jandal

    (@jandal)

    SOLUTION to A):

    function filterContent($content)

    replace

    function filterContent($content) {
            // If the user is logged in, return the content unfiltered.
            if (is_user_logged_in()) {
                return $content;
            }
    
            switch(true) {
                case is_home()    && $this->getOption('postspage_excerpts'):
                case is_archive() && $this->getOption('archive_excerpts'):
                case is_search()  && $this->getOption('search_excerpts'):
                case is_feed()    && $this->getOption('rss_excerpts'):
    					$content = get_the_excerpt();
    
                    break;
            }
    
            return $content;
        }

    With

    function filterContent($content) {
    		$proto       = is_ssl() ? 'https://' : 'https://';
            $redirect_to = urlencode($proto . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    
            // If the user is logged in, return the content unfiltered.
            if (is_user_logged_in()) {
                return $content;
            }
    
            switch(true) {
                case is_home()    && $this->getOption('postspage_excerpts'):
                case is_archive() && $this->getOption('archive_excerpts'):
                case is_search()  && $this->getOption('search_excerpts'):
                case is_feed()    && $this->getOption('rss_excerpts'):
    				if (has_excerpt()) {
    					$content = get_the_excerpt();
    				} else {
    					$content = 'Please <a href="' . site_url("wp-login.php?redirect_to=$redirect_to") . '">login</a> to view this post';
    				}
                    break;
            }
    
            return $content;
        }

    This at least stops the plugin from breaking the site. Now I just want to resolve B) above so only the “private” posts are affected.

    Thanks,
    James
    =-)

    Thread Starter Jandal

    (@jandal)

    FULL SOLUTION

    function filterContent($content)
        {
    		$proto       = is_ssl() ? 'https://' : 'https://';
            $redirect_to = urlencode($proto . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    
            // If the user is logged in, return the content unfiltered.
            if (is_user_logged_in()) {
                return $content;
            }
    
    		$content_login = '<br />Please <a href="' . site_url("wp-login.php?redirect_to=$redirect_to") . '">login</a> to view this post';
    		$page = get_page($page_id);
            if (MemberAccess::isPrivate($page)) {
    			switch(true) {
    
    				case is_home()    && $this->getOption('postspage_excerpts'):
    				case is_archive() && $this->getOption('archive_excerpts'):
    				case is_search()  && $this->getOption('search_excerpts'):
    				case is_feed()    && $this->getOption('rss_excerpts'):
    					if (has_excerpt()) {
    						$content = get_the_excerpt();
    					}
    					$content .= $content_login;
    					break;
    			}
    		}
            return $content;
        }

    It would be great to see Chris Abernethy work this into an update soon.
    Thanks,
    James
    =-)

    Hi Jandal,
    I’m having problems with this plugin and you seem to know what to do. Can you help? The main issue I’m having is that when a post is member only, the excerpt is not showing on the homepage even though excerpts are generated automatically with every post by the template I’m using.
    I only want to make the most recent post private, not all of the home page posts at this stage. Thanks.

    Thread Starter Jandal

    (@jandal)

    G’day ruba11,

    I have not looked at your problem in detail, but have you applied my patch above? It sounds like this might resolve it.

    I see that it has still not been added to the latest version of the plugin.

    Just apply my FULL SOLUTION to the page /member-access/lib/MemberAccess.php

    If you are not so web savvy and have wordpress 2.7+,
    * I would download and unzip a new copy of the plugin,
    * find the file in question,
    * open it with notepad (or your fav text editor)
    * fully replace the function in question.
    * save and close the file, in windows you can drag and drop the updated file back into the zip archive you downloaded. Make sure you drag and drop it back to the right directory.
    * on your wordpress install, delete the member access plugin
    * then using the “Add New” feature in your plugin menu find the updated plugin zip file and upload.

    I hope this helps out.
    Thanks,
    =-)

    Thread Starter Jandal

    (@jandal)

    Ruba11,

    Try my unofficial patched version
    https://jamesturner.co.nz/otherstuff/wordpress/member-access.1.1_unofficial.zip

    Thanks,
    =-)

    I have a question for you guys here then…

    User Access manager in 2.8 is showing me logged out in my link for login/logout on my home page even when logged in while using the Access manager.

    I’ve even tried switching the home page to a different page to see if it was my template and while using the plugin, no matter what page I assign as the home page, the login logout link shows me logged out on that page only…all the other pages shows logged in.

    Anyone have an answer for that?? Any help would be appreciated!

    Thread Starter Jandal

    (@jandal)

    G’day FireHouse,

    Please share all your Member Access settings.
    I’m unable to replicate the issue you are having?

    Are you using my unofficial patch?

    Thanks,
    =-)

    No, I am not using the unofficial patch, but I am using WordPress version 2.8 . I’ve never had this issue until I started using 2.8 were you working in 2.8 by chance?

    Seriously I have a tiny bit o money to add to someone’s paypal account if I give you login credentials and fix this up so it works properly..

    Let me uninstall and try the unofficial patch, see if that fixes the issue, then I’ll re-post and let you know the outcome.

    You interested in fixing this for a little money?

    Jandal,

    your patch fixed my problem as well. I hope the plugin author updates his files with yours..!!!

    You are awesome for helping everyone. I’ll send you a few dollars to your paypal account for helping keep this plugin alive and working in top shape. Plus I may need a php programmer for some extra functions or custom plugins..if you are interested send me your email and details to gogarza(((at)))gmail(((dot)))com

    well, POOOO , it DID NOT fix my issue strangely enough. I go back to home page after logging in and it works, but upon page refresh or going back to the home page again later, the home page still shows I am not logged in…???

    oh, and I am using the default settings, even went to reset. The error starts occurring as soon as I activate the plugin, I dont even have to have a new group yet.

    one other thing, sorry for so many posts…
    I am on a temporary url, using an I.P. address on my web hosts server for right now, so can that be the issue??

    okay, it seems it is a routing issue with my host I.P. should rectify itself once the the site goes live. Sorry for the gazillion posts.

    Thread Starter Jandal

    (@jandal)

    Please give me an update when you are on a stable connection.

    I have had word from the Author, he mentioned he will do his best to make updates soon.

    I had upgraded my install to 2.8, and was not able to replicate.

    Sending email.

    =-)

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘[Plugin: Member Access] Posts Page Settings’ is closed to new replies.