Skip Navigation

[Resolved] Showing logged in user posts

This support ticket is created 4 years, 1 month 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 14 replies, has 2 voices.

Last updated by Lee Drozak 4 years ago.

Assisted by: Shane.

Author
Posts
#1576089

Tell us what you are trying to do?
I'm recreating a directory using block editor but can't figure our how to conditionally show a looped view

[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq 'true' )"]
[wpv-view name="listings-of-the-logged-in-user"]
[/wpv-conditional]
[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq 'false' )"]
Only logged-in users can see their listings. Please log in to view your listing.
[/wpv-conditional]

Is there any documentation that you are following?
Directory tutorial for classic cars

Is there a similar example that we can see?
Directory tutorial for classic cars

I have not installed views because I want to keep everything in the block editor. Is this not possible?

#1576171

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Lee,

Thank you for getting in touch.

Actually this should work however the comparison values shouldn't be the text "true" or "false". Rather it should be 0 or 1 because the shortcode should return a 0 or 1.

So the correction should be

[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq '1' )"]
[wpv-view name="listings-of-the-logged-in-user"]
[/wpv-conditional]
[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq '0' )"]
Only logged-in users can see their listings. Please log in to view your listing.
[/wpv-conditional]

Please let me know if this works now.
Thanks,
Shane

#1576209

Where do I add the condition? The condition block does not have a current user condition.

#1576263

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Lee,

Sure in the block editor, you will add a Classic editor. See Screenshot

This will give you a regular WYSIWYG editor where you can just paste the shortcode in and it should start working.

The code is being used on a simple page using the wordpress Gutenburg editor correct?

Thanks,
Shane

#1576463

Do I still need to add views in order to use the loop to pull user generated content?

#1577193

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Lee,

For clarity this is for a user's profile page correct?

This view there is listing out the information for the currently logged in user
[wpv-view name="listings-of-the-logged-in-user"]

If so then you won't actually need it if you are getting the information from the user's profile itself.

You can just wrap the shortcodes that are in this view in the conditionals like this

[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq '1' )"]
Username: "types shortcode goes here"
Additional Info: "types shortcode goes here"


[/wpv-conditional]
[wpv-conditional if="( '[wpv-current-user info='logged_in']' eq '0' )"]
Only logged-in users can see their listings. Please log in to view your listing.
[/wpv-conditional]

This is because those fields will automatically get the info from the currently logged in user.

Please let me know if this is clear or if further clarification is needed.

Thanks,
Shane

#1577929

The view is not yet created. I have the bones of the My Listings page but can't figure how to create the view and wrap it. Do I use the classic editor on all pieces? Meaning do I create the view here or somewhere else?

I tried to activate the Views Add-on but this the block editor it won't allow hence the confusion.

#1578641

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Lee,

Before we proceed further to ensure that is no confusion could you answer the following questions.

1. What is it that the view is going to display?

2. Will you be creating a page to add this view on?

3. I assume the view should only be displayed to logged in users.

With this I can get some clarity on the best direction to take in guiding you to achieve your desired results.

Thanks,
Shane

#1578927

1. What is it that the view is going to display?
An overview of the posts they submitted >> title with URL, post date that should lead to the edit existing listing form

2. Will you be creating a page to add this view on?
yes, My Listing Page

3. I assume the view should only be displayed to logged in users.
Correct

I have a listing page that was created with blocks that is an archive page and I've creates the edit listing form by I can't get the My Listing page to show submitted listings or how to show so they can be updated.

#1579019

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Lee,

An overview of the posts they submitted >> title with URL, post date that should lead to the edit existing listing form

Thanks for the clarity on this one. In this case based on your setup you will need to create your view by going to Toolset -> Views. If this option doesn't appear go to Toolset -> Settings and scroll to Editing Experience and select "Show both the legacy and Blocks interface and let me choose which to use for each item I build"

Once you have done this you will see the views menu. This should now allow you to create your view.

When your view is finish you can now call it using the view shortcode and wrap it within the conditional code.

"I have a listing page that was created with blocks that is an archive page and I've creates the edit listing form by I can't get the My Listing page to show submitted listings or how to show so they can be updated."

For clarity this archive listing you want to put it on a specific page ? I'm not quite sure what you mean by the statement above.

Thanks,
Shane

#1580249

I'm totally frustrated! It's difficult to try and learn how to create using your tools when the demos and tutorials are outdated.

I'm trying to follow the auto listing directory but all of the instructions are based on pre block instruction. Nothing is working as hoped because there are no tutorials that are block based.

I've wasted a lot of time trying to piece a dev site together. I was hoping to build using Toolset with Gutenberg, Beaver Builder and WooCommerce but seriously rethinking this plan when there are other more up to date options.

#1580273

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screenshot 2020-04-09 at 3.58.04 PM.png

Hi Lee,

I Understand the frustration but there are limitations that we are working with.

Firstly this thread is about Showing/Hiding a view based on whether a user is logged in or not. Right now this post in the link below address and resolves the issue.

https://toolset.com/forums/topic/showing-logged-in-user-posts/#post-1576171

Secondly you asked "Where do I add the condition? The condition block does not have a current user condition."

Assuming that you are writing out the shortcodes we would be talking about using the Classic editor block on your Page. See Screenshot

Essentially this screenshot is exactly what you should have for your conditionals to switch between logged in users and logged out users.

Your next query was

"The view is not yet created. I have the bones of the My Listings page but can't figure how to create the view and wrap it. Do I use the classic editor on all pieces? Meaning do I create the view here or somewhere else?"

Now because of your initial post I'm under the impression that :
1. Your view was already created.
2. You Have your page setup for the view.
3. You only need to use conditional to display or hide the view.

These were the assumptions that I was using to guide my responses in assisting with resolving the issue.

Now if you say your view was not yet created and you have a Listings page. This would introduce a bit of confusion as now i'm not sure where you are in your development process.

You mentioned "can't figure how to create the view and wrap it".

Now I understand what you mean by you cant figure out how to create your view, in which I responded with "In this case based on your setup you will need to create your view by going to Toolset -> Views. "

I've also mentioned that if you're not seeing this option you should " go to Toolset -> Settings and scroll to Editing Experience and select "Show both the legacy and Blocks interface and let me choose which to use for each item I build"

At this point its a bit of confusion as i'm not sure where you are in your project or what you have setup already.

In my thought process your Thread is about "Listing out a User's Posts when they are logged in".

Please provide clarification on what exactly you want me to assist you with as I believe we are straying from what the exact issue is.

Thanks,
Shane

#1584427

Thanks for your patience. I was able to cobble together my solution by following a newer tutorial and the older one. You have been amazing and as always support is fantastic.

#1585461

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Lee,

I'm happy I was able to get the ball rolling for you on this.

Was I able to help you to fully resolve your issue or are there further queries on this issue.

Is there anything you're unsure about on this issue ?

Please let me know. If not then you can go ahead and mark this ticket as resolved.

Thanks,
Shane

#1585501

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.