Skip Navigation

[Resolved] Single Post view depending on status of user

This support ticket is created 5 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 12 replies, has 2 voices.

Last updated by Doug Watt 5 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1307375
Capture.JPG

Tell us what you are trying to do?
I am trying to display a view of a single post (a cartoon image drawn from Cloudinary) in a different way depending on whether the user is a logged-in administrator, or a guest.

1. A logged-in administrator would search for posts using a search facility on the site and on selecting a single post they would click on the link and be taken to a CRED form to edit the post. This is all working well.

2. A guest may find the post thru a Google search and when clicking on the link I want them to be directed to a view showing only the Post Title and the image of the cartoon.

I have it set up this way:
The single post view is controlled by a template called "edit strips" which looks like this:

[toolset_access role="Administrator"][cred_form form='edit-comics'] [/toolset_access]
[toolset_access role="Guest"][wpv-view name="single-cartoon-strip"][/toolset_access]

This works properly for administrators, in they they are directed to the CRED form to edit the post.

Guests are directed to the view - but a random post is displayed.

What have I done wrong??

What is the link to your site? hidden link

#1307465
Ordering.JPG

Hello,

How do you setup the view "single-cartoon-strip"? Please edit it, you can find the "Ordering" setting, see screenshot:
Ordering.JPG

If you are using random order setting in above view, you will need to change the order setting to something else, for example order by post date.

If the problem still persists, please check these:
1) Make sure you are using the latest version of Toolset plugins, you can download them here:
https://toolset.com/account/downloads/

2) In case it is a compatibility problem, please deactivate all other plugins, and switch to wordpress default theme 2019, deactivate all custom PHP/JS code snippets, and test again

#1307581

Hello Lou Yang,

I have worked through these steps and the problems remains.

If I set Order By to "random", that's exactly what I get - a random display ...but not the one as indicated in the slug being requested.

Do I need to set a filter that will only display the post that is requested by what is typed in the browser?

Regards,

Doug
====

#1307599

Which post do you want to display in View's result?
If it is a post specific by post ID, you can add a filter in view "single-cartoon-strip", for example:
Include only posts with the following IDs: 123

See our document:
https://toolset.com/documentation/user-guides/filtering-views-query-by-post-id/

#1307615

Hello Lou Yang,

I am looking to display whichever post is called by a guest to the site. This would most likely be thru clicking on a link from a search engine. So a typical request would be for :

hidden link

where "bob-pass-the-soap" would be the slug of the requested post.

Doug

#1307619

I have tried the URL you mentioned above, but I can see only 404 error:
Oops! That page can’t be found.

Dose this post "bob-pass-the-soap" exist in your website?
If it exists in your website, how do you setup this post? you will need to make sure that post is view-able for guests.

#1308327

I'm sorry, but I gave you the wrong URL. I was "out and about" at the time that I replied and I got it wrong. 🙁

Some typical URLs would be as follows:

hidden link

hidden link

hidden link

If you click each of these, you'll see that same comic displayed - even though the URL showing in the browser's address bar is for the comic that you clicked on.

Doug
====

#1309089

Yes, I can see the problem as you mentioned above: that same comic displayed.

I assume you are going to display the current "comic" post information.
If it is, you don't need that post view (ID 2069), you just need to setup a content template for single "comic" post, see our document:
https://toolset.com/documentation/user-guides/view-templates/

#1310121

Lou Yang,

I seem to have got lost somewhere in the back and forth. Can I ask the question again in the simplest form that I can?

The custom post type "comic" is displayed in a number of different ways on this site: in various sliders and collections, etc. However, it's the single post view that I'm having trouble with.

I need this single post display to achieve two different things:

1. For guests coming from a search engine (or somewhere else out side of this site), I just need then to see a view of the comic image and maybe a call-to-action button.

2. But for logged-in administrators, I need them to be able to see the image along with the "edit content" form that is associated with the post type. These posts are entered and edited thru a CRED form.

I have Access installed and I had intended to use a conditional display to direct guests and administrators to different "views" of the single post.

1. Is this possible?
2. Am I approaching it correctly?

I had established a content template containing the following:

[toolset_access role="Administrator"][cred_form form='edit-comics'] [/toolset_access]

[toolset_access role="Guest"][wpv-view name="single-cartoon-strip"][/toolset_access]

This worked for the administrators, but for guests, it simply displayed a random post.

can you see what I'm try to do?

Many thanks,

Doug
====

#1310145

Dear Doug,

Yes, it is possible, and I think you are using correct approach.

For the problem you mentioned above:
Post view "single-cartoon-strip" displayed a random post
So the problem is in that above post view "single-cartoon-strip".

I assume you are going to display a custom image field/featured image of current "comic" post.
hidden link

If it is, you don't need that single post view "single-cartoon-strip" at all, you can try these:
1) Create a new content template "comic-for-guest"

2) Display the custom image field/featured image shortcodes in above content template
https://toolset.com/documentation/customizing-sites-using-php/functions/#image
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-featured-image

3) Modify this line of your codes from:
[toolset_access role="Guest"][wpv-view name="single-cartoon-strip"][/toolset_access]

To:
[toolset_access role="Guest"][wpv-post-body view_template="comic-for-guest"][/toolset_access]

More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-body
Outputs the content of the current post or renders a content template

If you need more assistance for it, please provide a test site with the same problem, I can setup a demo for you.

#1313775

Thank you for all of your help with this issue, Lou Yang.

I finally found the basic problem was that I had already created a single post template for the post type "comics" using the Theme Builder in Elementor. I had forgotten to "unassign it".

Once I did that, everything we have discussed in this thread began to work properly. 🙂

Thanks again.

Doug
====

#1314111

Thanks for the sharing the solution, feel free to create new ticket if there is other new questions.

#1314127

My issue is resolved now. Thank you!