I'm hoping to have a profile page for users that has a custom layout (can build out with the Toolset tools). Ideally where if the logged in user views their page, they get a bit more info (in particular going to show posts they've bookmarked), but if a non-logged in user, or a different user views the page, they get similar info but not seeing the bookmarked (and maybe other stuff).
Is there a good way to do this? If we need two different pages, can do that if needed but would prefer one page that can serve both.
Hi,
Thank you for contacting us and I'd be happy to assist.
If you're looking to create a unique profile page for each of your users, you can register a custom post type "User Profiles" and make sure that every user submits a form to create exactly one post in this post type, after registering.
( that post's single page will serve as each user's profile page )
This approach is explained in detail here:
https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/
As for the content on that profile page, I understand, you'd like part of it shown only to the user whose profile page is being viewed.
( hiding it from non-logged in visitors as well as from other logged-in users )
This can be easily achieved through the conditional display feature:
https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/
For example:
[wpv-conditional if="( '[wpv-user field='ID']' eq '[wpv-post-author format='meta' meta='ID']' )"]
The visitor is the author
[/wpv-conditional]
The above code block when placed inside a template for a single profile post page, will only show "The visitor is the author" content when the ID of the currently logged-in user ( [wpv-user field='ID'] ) and the ID of the post author of the current user profile ( [wpv-post-author format='meta' meta='ID'] ) are equal, which means they are the same person.
You can read more about these and other available shortcodes from:
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-user
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-post-author
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
My issue is resolved now. Thank you!
Well I'm getting closer, but I can't seem to get to the conditional code area. I'm not using the views plugin but using the blocks one (messaging when installing seemed to not want me to have both). Do I need to use views? Or where do I go in blocks to get this logic?
Also, it looks like I'm going to need to create a custom filter and that would get applied to the view contents (need to query a list of post ids that are stored in a user meta field). Possible? Any tips?
Thanks again for your help
I found the conditional block and got that working. So let me know if I need to open a new ticket but just want to see if it's possible to have the View block use a shortcode to get the items to loop through/filter (will have to build out the short code function but I can figure that out)