Hey
I am trying to user a view that generates a list of post IDs and then use this view to filter another view.
The exact code I am using is below:
[wpv-view name="my-tracked-shows-individual-tv-show-listing" showids="[wpv-view name="my-tracked-shows-just-ids" userid="[get_user_id]"]"]
However it doesn't work.
It does work when I use:
[wpv-view name="my-tracked-shows-individual-tv-show-listing" showids="[wpv-view name="my-tracked-shows-just-ids"]"]
but this doesn't filter down by current User ID then.
When I add in the user id part Toolset seems to save the code odd and cut the end part off.
Hi, what if you alternate nested single and double quotation marks like this:
[wpv-view name="my-tracked-shows-individual-tv-show-listing" showids="[wpv-view name='my-tracked-shows-just-ids' userid='[get_user_id]']"]
Also please confirm that get_user_id is registered in Toolset > Settings > Front-end Content > Third-party shortcode arguments.
If neither of those seems to fix the issue, I'll need to take a closer look.
Hmm Yeah I think this is working thanks, my issue is get_user_id is not right now. This is getting the User ID of the person who created the page not the current user.
I tried setting up the following:
function get_currrent_userid() {
$user_id = get_current_user_id();
return $user_id;
}
add_shortcode( 'get_current_userid', 'get_current_userid' );
However this isn't working :-/. Normally I would use [wpv-user field="ID"] but this won't work as its too many " and ' I think, even alternating it messes up. So I think I just need to create a Shortcodes for the current User ID, could you help with this? 🙂
Cheers!
Spent ages on that trying to figure out why it wasn't working and as I posted I noticed my typo!
So the get_current_userid Shortcode works now but unfortunately its still not working.
So: [wpv-view name="my-tracked-shows-individual-tv-show-listing" showids="[wpv-view name='my-tracked-shows-just-ids' userid='18']"] works fine.
However: [wpv-view name="my-tracked-shows-individual-tv-show-listing" showids="[wpv-view name='my-tracked-shows-just-ids' userid='[get_current_userid]']"] does not work.
I used [get_current_userid] on the page and its showing the current user ID so this is 100% working.
Ah okay great. Thanks for reporting back.
No problem but sorry probably wasn't clear that it still doesn't work.
So: [wpv-view name="my-tracked-shows-individual-tv-show-listing" showids="[wpv-view name='my-tracked-shows-just-ids' userid='18']"] works fine.
However: [wpv-view name="my-tracked-shows-individual-tv-show-listing" showids="[wpv-view name='my-tracked-shows-just-ids' userid='[get_current_userid]']"] does not work.
For some reason when I use the shortcode (which 100% works now on its own) it breaks it.
On its own: [wpv-view name='my-tracked-shows-just-ids' userid='[get_current_userid]'] works fine. It outputs the ID numbers fine.
However as soon as its put it in the other view it breaks if [get_current_userid] is used, as I mention if I just hard code a user ID number it works fine.
Realised this ticket was closed so following up to my last message and reopening.
So to summarize:
[wpv-view name="my-tracked-shows-individual-tv-show-listing" showids="[wpv-view name='my-tracked-shows-just-ids' userid='18']"] works fine.
[get_current_userid] by itself outputs 18 on the front-end.
But... [wpv-view name="my-tracked-shows-individual-tv-show-listing" showids="[wpv-view name='my-tracked-shows-just-ids' userid='[get_current_userid]']"] does not work.
The only thing I can think is that get_current_userid is not registered correctly in Toolset > Settings > Front-end Content > Third party shortcode arguments. Please check.
Hey Christian,
Yes correct the following works fine:
[wpv-view name="my-tracked-shows-individual-tv-show-listing" showids="[wpv-view name='my-tracked-shows-just-ids' userid='18']"]
[get_current_userid] by itself outputs 18 on the front-end. - Yes correct. In a toolset view so I believe that confirms Toolset understands it but it is 100% in third party shortcode arguments anyway. Just double checked.
The following does NOT work correct.
[wpv-view name="my-tracked-shows-individual-tv-show-listing" showids="[wpv-view name='my-tracked-shows-just-ids' userid='[get_current_userid]']"]
It also outputs results that seem random and displays "] on the page so its like it messes up for some reason.
Cheers
Okay and what is the output of just these two shortcodes alone:
[wpv-view name='my-tracked-shows-just-ids' userid='[get_current_userid]']
Hey Christian,
So the code you mentioned outputs in this example: 29450,22477,90503,30162
The exact same result I get if I use:
[wpv-view name="my-tracked-shows-just-ids" userid="1"]
(logged in as User ID 1 at present).
So both output the same result when used on their own but when used within
[wpv-view name='my-tracked-shows-individual-tv-show-listing' showids='X']
only the one where the userid is hard coded, works.
29450,22477,90503,30162
If you inspect this output in the browser, are extra line breaks shown above or below the numbers? If so, that could be breaking the shortcode attribute algorithms. If there are extra line breaks, you may need to strip out extra spaces from the View's loop and templates.
If not, I'll need to log in and take a closer look. Please provide login credentials in the private reply fields here and tell me where I can see these shortcodes on the front-end of the site.
It's tricky, but here's a screenshot showing the extra linebreak problem. I edited the View "My Tracked Shows - Just IDs" and stripped out all the remaining line breaks, and it seems to be working for me now (I had to temporarily change the User ID for one of the shows, but I changed it back).
Hi Christian
Really? What do you see on the actual page? As I am still having the same issue. :-/
Just disabled Cloudflare to see if it was a caching issue but that didn't make any difference.
See the before and after pics here. Before is before I changed this User Show: hidden link
After is after I changed the User ID in that User Show to 19, which is what is returned by get_current_userid when I'm logged in. I also modified the "Testing version with id manually passed" shortcode to manually pass in 19.