Tell us what you are trying to do?
I have a View and want to show the post based on the query filter custom email field is equal to the current login user email.
In settings->Frontend content-> third party shortcode I added wpv-current-user
In view->content selection->query filter added Custom email field equal to shortcode attribute useremail.
Custom email field is a string equal to VIEW_PARAM(useremail)
But I am not sure how to pass this. Where do I need to place this?
[wpv-view name="viewname" useremail="[wpv-current-user info="email" ]"]
I searched several topics but it's not clear how to use this.
Is there any documentation that you are following?
https://toolset.com/forums/topic/filter-view-by-custom-field/
https://toolset.com/documentation/legacy-features/views-plugin/passing-arguments-to-views/
Please guide me on how to use this shortcode attribute.
Hi there
It's not clear if you are using the block editor or the legacy editor.
Passing arguments to a View via shortcode attributes is essentially a feature of the legacy editor, inasmuch as you can only add a shortcode attribute when inserting a View using the wpv-view shortcode. If you insert a View using blocks there is no way to provide such a shortcode attribute.
Regardless of whether you created a View with the legacy editor or with the block editor, to pass a shortcode attribute you must insert the View where it is needed via the wpv-view shortcode.
If you are using the block editor this may not make sense, in that you already created the View in-situ on a page, which may be where you want the View to appear.
A better option in that scenario might be to use the Views API instead. Remove the query filter that you added to the View and use the wpv_filter_query API hook to add a meta_query condition for the custom email field to see if it matches the email address of the current user.
See https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
If you need help with that, let us know.
Hi Nigel,
Thanks for supporting.
I use Block Editor. I followed these steps and it seems it works for now.
I created two pages.
First page -> Created view(view name= test) with post type and query filter custom field equal to VIEW_PARAM(useremail) and added details post title etc..in view loop.
Second page-> I insert shortcode [wpv-view name="test" useremail="[wpv-current-user info="email" ]"] using the shortcode widget and when I publish and see this page. I can see the list of posts by the current user email.
Thank you for confirming it worked.
I hope we are good to close here.
Feel free to contact us any time if you need assistance with our products.
Kind regards