[Resolved] View shortcode UserID not returning expected value
This support ticket is created 3 years, 6 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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Tell us what you are trying to do?
To create a page which shows a user's own profile, so I'm using a shortcode to insert a view with an extra param to filter by the current user ID.
I'm using the shortcode:
[wpv-view name="my-profile-header" userid="[wpv-current-user info='id']"]
But the correct info isn't showing. When I change the shortcode to simply output the userID so that I can check it ([wpv-current-user info="id"]) it simply outputs the digit 1 instead of the correct user ID. Other variants such as [wpv-current-user info="username"] work, however.
I did notice that when I add that full shortcode I get the view output but there's an errant "] after it, like the shortcode isn't being parsed properly?
This should work as intended as i've tested it out on my end and it works fine. Would you mind allowing me to have admin access to the site so that I can test this out on your end to see what is happening.
I've enabled the private fields for your next response. Please also send me the page that the view is on.
The problem is caused by the elementor shortcode block. It doesn't allow for you to nest the shortcodes. I've added the shortcode to their Text Editor block which works without breaking the shortcode.
hidden link
You can go ahead and remove the shortcode block from the template once you can confirm that the workaround is fully functional.
The shortcode seems to be properly parsed now however [wpv-current-user info='id'] is still returning the value "1" for me rather than the correct logged in userID?
My mistake, I was getting the results whilst in Elementor edit mode which didn't seem to properly get my User ID, however when viewing on the frontend it worked as expected.