Support Forum

Manually inserted template tags are ignoring permission sets, not showing topic headlines to guests (who are allowed to see them)

RL Robert Lawrence
Robert Lawrence
Member

I am using a template tag to pull in a list of recent forum posts into a page and was having some issues before, (in another thread) which is solved.

https://simple-press.com/support-forum/sp5-plugin-topics/problem-with-post-edit-buttonow-to-remove-the-word-topic-in-newest-topics-tag-php-raw-code/page-2/#p123105

This is a separate and unique issue so I thought it best to start another thread in case anyone else is having this new issue.

The issue I am having now is that the template tag now only shows up to users who are logged into the site.  For guests, the template tag doesn’t pull in any topic headlines at all. 

I checked the permission sets and guests “Can view a list of forums and list of topics only” but can’t do anything else and are hit with the page redirect (just like how you have it here on this Simple-Press help forum).  This worked fine when I was using the recent posts widget, but it seems that the recent posts template tags don’t follow theses same permissions.  It just doesn’t show the output of the template tag at all.  It’s blank.

To test this, I changed the permission set for guests to allow everything and the template tag worked and pulled in the topic headlines like it is supposed to be doing. (But the forum and everything is now open, which I don’t want it to be). 

I switched the permissions on guests back to “Can view a list of forums and list of topics only”  and the recent posts tag did it again and everything disappeared.   It’s not showing the topic headlines at all, even though I am allowing guests to view these.

(I cleared the cache in both the browser and the host each time and tested it in several browsers and had the same result.)

The template tags should follow the user permissions granted and show what is allowed to be shown to each user group.  The recent posts widget does this fine, but for some reason the template tags on their own don’t follow the permission sets. 

How do I fix this so I can show a list of topic headlines to guests (and when they click on a link get redirected to a page)?

 

 

22 Answers

New Answer

MP Mr Papa
Mr Papa
Member

so what template tag are you using?  the recent posts template tag and the recent posts widget all share the same code…

RL Robert Lawrence
Robert Lawrence
Member

Yes, it’s the recent posts template tag.  I re-tested the recent posts widget and it works fine.  But the recent posts template tag doesn’t follow the permissions set or show up for guests (even though they are allowed to view the forum and list of topics).  But when I changed the permissions to guests to “full access”, the template tag worked fine and the topic list and everything shows up (and they can view the contents of all posts in the forum, which is NOT what I want them to do). 

When I switch the guests back to just being able to view just the forum and topics list, then the recent posts template tag doesn’t work and nothing is displayed.  It doesn’t pull in anything.

Also, I cleared the cache in both the browser and at the host each time.   The only thing I switched was the permission set for guests (in order to test it).  So I know that the recent posts template tag isn’t accepting the permission “Can view a list of forums and list of topics only”.  It’s ignoring it. 

I also tried it switching it on and off several times (to make sure that the permission would stick and stay green) and the template tag just ignores it and displays nothing.  But, the recent posts widget works fine and follows all permission changes each time I make the switch (on or off).

My site is http://membershipexpert.com

You can see on the left hand side (scroll down) the recent posts widget (says “recent forum posts), which I have there for testing purposes. 

The recent post template tags are in the middle of the page (main area) and under the title “Hot Topics In The Members Discussion Forum”. This is where I want to show recent activity happening in the forum.

The recent posts widget works fine.  The template tag just doesn’t show up (unless I change the permissions for guests to full access to be able to view everything). 

Somehow, the recent posts template tag is not taking the permission: “Can view a list of forums and list of topics only”, but the recent posts widget does.

 

 

BR Brandon
Brandon
Member

Robert Lawrence said
Somehow, the recent posts template tag is not taking the permission: “Can view a list of forums and list of topics only”, but the recent posts widget does.
 

You mean the Hottest Topics template tag is not displaying anything for view/read only guest permissions but the Recent Posts ones does. Right?

I did a quick test and I cannot duplicate the issue. Do you have Guests and their Permission Read only added to all the groups and forums?

MP Mr Papa
Mr Papa
Member

yes, this was noticed a few days ago… Is this still the case in the template tags release pushed out last night?

RL Robert Lawrence
Robert Lawrence
Member

Mr Papa said
yes, this was noticed a few days ago… Is this still the case in the template tags release pushed out last night?

 

I just installed the plugin update for template tags and tested everything again as described above and the problem is still there.  It doesn’t appear fixed.  I also uninstalled the plugin and reinstalled it fresh and it’s still happening. I cleared all cache, etc.

The recent forum posts template tag is not adhering to the permissions set for guests (“Can view a list of forums and list of topics only”.)  It’s ignoring it and displaying nothing.   The recent forum posts widget works fine and adheres to the permissions.  When I change the guest permissions to be able to view everything, then it works fine (but I don’t want to give guests full access)

I also set up a separate test page to make sure there was no other code or anything on the home page which was messing things up.  The test page is here: http://membershipexpert.com/test-page/  The same issue persists.  It made no difference.

The issue appears to be with the recent forum posts template tag.

 

RL Robert Lawrence
Robert Lawrence
Member

Brandon C said

Robert Lawrence said
Somehow, the recent posts template tag is not taking the permission: “Can view a list of forums and list of topics only”, but the recent posts widget does.
 

You mean the Hottest Topics template tag is not displaying anything for view/read only guest permissions but the Recent Posts ones does. Right?

I did a quick test and I cannot duplicate the issue. Do you have Guests and their Permission Read only added to all the groups and forums?

 

No, I’m not using the hottest topics template tag.  Just the recent posts template tag (which does not work). The recent posts widget works find and respects the permissions set.  I also checked both the group and forum permissions and they are both set the same, guests get read only access and can only view a list of forums and topics.  The issue seems to be with the recent posts template tag itself.

 

MP Mr Papa
Mr Papa
Member

well, you  missed my point earlier… did you not say the widget worked?  the widget actually calls the recent posts template tag…

so lets clear that up…  are you still saying the widget works but the template tag does not?? or did I misunderstand?

RL Robert Lawrence
Robert Lawrence
Member

Yes, the recent posts widget works fine. The recent posts template tag (by itself) does not work.  That’s the whole issue. 

I only put the widget on the page, so I could test it against the template tag because you said that they are both using the same code and should react the same way (when forum permission changes are made). They don’t.

It’s the template tag for recent forum posts that is having the issue.  It does not adhere to permissions set for guests.  But the recent posts widget does.  It makes no sense.  Something is wrong.

MP Mr Papa
Mr Papa
Member

agreed.. makes no sense… we will need to do some more testing… but here is what I am saying… this is the widget code that displays the data:

function widget($args, $instance) { extract($args); $title = empty($instance[‘title’]) ? __(“Recent Forum Posts”, ‘sp-ttags’) : $instance[‘title’]; $forumIds = empty($instance[‘forumIds’]) ? 0 : $instance[‘forumIds’]; $limit = empty($instance[‘limit’]) ? 5 : $instance[‘limit’]; $itemOrder = empty($instance[‘itemOrder’]) ? ‘FTUD’ : $instance[‘itemOrder’]; $linkScope = empty($instance[‘linkScope’]) ? ‘forum’ : $instance[‘linkScope’]; $beforeForum = empty($instance[‘beforeForum’]) ? __(‘Forum: ‘, ‘sp-ttags’) : $instance[‘beforeForum’]; $afterForum = empty($instance[‘afterForum’]) ? ‘
‘ : $instance[‘afterForum’]; $beforeTopic = empty($instance[‘beforeTopic’]) ? __(‘Topic: ‘, ‘sp-ttags’) : $instance[‘beforeTopic’]; $afterTopic = empty($instance[‘afterTopic’]) ? ‘
‘ : $instance[‘afterTopic’]; $beforeUser = empty($instance[‘beforeUser’]) ? __(‘By: ‘, ‘sp-ttags’) : $instance[‘beforeUser’]; $afterUser = empty($instance[‘afterUser’]) ? ” : $instance[‘afterUser’]; $beforeDate = empty($instance[‘beforeDate’]) ? ‘ -‘ : $instance[‘beforeDate’]; $afterDate = empty($instance[‘afterDate’]) ? ” : $instance[‘afterDate’]; $avatarSize = empty($instance[‘avatarSize’]) ? 25 : $instance[‘avatarSize’]; $niceDate = empty($instance[‘niceDate’]) ? 1 : $instance[‘niceDate’]; $postTip = empty($instance[‘postTip’]) ? 1 : $instance[‘postTip’];

# generate output echo $before_widget.$before_title.$title.$after_title; sp_RecentPostsTag($instance); echo $after_widget; }

note the call to sp_RecentPostsTag() which is what you say does not work…

so quite mystified…

RL Robert Lawrence
Robert Lawrence
Member

Yes, it’s very strange.  Maybe you can try to recreate the issue and see if it happens. 

If the widget works fine, I don’t know why the template tag itself wouldn’t work and obey the permissions for Guests.  Maybe it’s because I am just pulling in the topic headlines and excluding all of the rest of the stuff that the recent posts widget usually pulls in?

Any other ideas?

YS Yellow Swordfish
Yellow Swordfish
Member

Nothing specific… This is the same code – the same function in the same file.
About the only question I can think of asking is where are you comparing these? I.e., where do you run the widget and look at the results – and where do you run the raw template tag and view the results?

RL Robert Lawrence
Robert Lawrence
Member

They are being run on my homepage at http://membershipexpert.com

The recent posts template tag is being run in the middle section which says: “Hot Topics In The Members Discussion Forum” and is using the plugin “Allow PHP In Posts And Pages” using a shortcode called “php function=1″ which you will see if you view the source on this page.

The code I am using in the shortcode is:

<?php sp_NewestTopicsTag('itemOrder=T&limit=10&beforeTopic=&afterDate=');?>

The recent posts widget can be seen in the footer of the page if you scroll down to bottom, under the heading “Recent Forum Topics”

Currently permissions for guests are set at: “Can view a list of forums and list of topics only” and it works fine for the recent post widget and performs like it is supposed to.  Shows guests the topic list then when they click on it, gets redirected to the sales page.

But, the recent posts template tag will NOT show anything unless I change the forum permissions for guests to be able to view everything, including contents of posts within topics.  Then the template tag works and shows a list of the most recent 10 topics (but gives full access to forums and all topics and contents of posts to the guest, which is not what I want it to do).  I also cleared the cache each time I tested it across multiple browsers and cleared the cache at the host, with the same result. 

Somehow, the template tag (by itself) is ignoring the forum permissions of “Can view a list of forums and list of topics only” but the widget obeys it.

Makes no sense at all.

 

 

 

 

YS Yellow Swordfish
Yellow Swordfish
Member

The ‘Newest Topics’ Tag is NOT the same thing as the ‘Recent Posts’ tag and the ‘Recent Posts’ widget. I will look at the code of the Newest Topics tag to see if there are any shortcomings in the permission checks but they are different things that use a completely different class to populate them.

Sorry – but you did say earlier that this was the Recent Posts tag you were using.

RL Robert Lawrence
Robert Lawrence
Member

Ok, looks like I was getting confused because it was said they were using the same code so I thought they were the same since I was only using the widget to pull in topics.  But now it all makes sense. 

The issue seems to be with just the Newest Topics tag and the permission checks.