Magic Tag not Working for Pick Column
I have a Pod called 'classified_ads', one of the columns is a pick to WP User called 'wp_user'.
In my template, I cannot for the life of me get the user ID outputted with magic tags. The template is being called by shortcodes in a WP Page.
For example {wp_user.ID} yields nothing. All the other columns magic tags function as expected.
However if I use PHP like so, it does get output:
<pre> $ads = new Pod('classified_ads'); $ads->findRecords(); while($ads->fetchRecord()): echo $ads->get_field('wp_user.ID'); endwhile; </pre>
That will give me the correct IDs, but why wouldn't the magic tags work the same?
My DB prefix is not the default 'wp_' if that has anything to do with it.
Thanks for any ideas on this.
5 Answers
EDIT -
I am using the magic tag as {wp_user.ID} NOT without the '@' symbol as indicated above.
Double check your template. Are you sure that the tag is showing up with the @? When saving stuff to the database (such as templates or pages), Pods automatically replaces any instance of '@wp_' with the database prefix - this is a side effect of the pod_query() function.
tokyograph is actually correct, however, I've got a patch that will be going into 1.8.2 which will solve this issue going forward.
Pods currently automatically replaces all instances of "wp_" with your table prefix. As a side effect, this replaces any instances of "wp_" in your code as well.
My fix just finds all "{wp_" and replaces it with a Pods internal variable which will get replaced after the initial "wp_" replacement is done, which then is switched back to "{wp_" so your code remains untouched.
As proof of the issue, you can see how in this thread, it's gone and done it too ;)
Our new forums will have a fix which will secure them further from this type of stuff too, so even if they enter @ wp_ (without the space) it won't show the template. We'll release the Pre Save Helper that makes that possible separately.
So, to resolve this I renamed my pick column from 'wp_user' to 'wordpress_user' and now it works as expected.
I couldn't find any way of making it work without changing the column name.
Thanks Scott and tokyograph!


