I'm trying to conditionally show some user fields at user page.
This is front:
[wpv-conditional if="( '[types usermeta='twitter' user_id='[queried_object_id]' output='raw'][/types]' ne '' )"]
<li><a href="[types usermeta='twitter' user_id='[queried_object_id]' output='raw'][/types]" class="twit2" target="_blank" title="Twitter"><i class="fa fa-twitter"></i></a></li>
[/wpv-conditional]
There is shortcode:
function queried_object_id( $attr ) {
return get_queried_object_id();
}
add_shortcode( 'queried_object_id', 'queried_object_id');
Functions registered:
hidden link
But this conditional is always false and nothing is shown...
How to fix it?
Toolset User Fields are not appearing in the GUI for conditional output.
I reported this so we can work on this problem.
To check upon user Fields you can do this:
[wpv-conditional if="( '[types usermeta='your-field-slug' user_is_author='true' output='raw'][/types]' eq 'here' )"]
Output if value is "here"
[/wpv-conditional]
But that works only where you have a Post Object and an author - or if you pass an User ID, or the current logged in user.
It seems you want to do that on the Author Archives and there you have no author of a post as usual.
get_queried_object_id() returns just the right value.
You can try this with the simple shortcode:
function my_object(){
$object = get_queried_object_id();
var_dump($object);
}
add_shortcode('my_object', 'my_object');
Hence you can use that ShortCode in a condition like this:
[wpv-conditional if="( '[types usermeta='your-field-slug' user_id=='[my_object]' output='raw'][/types]' eq 'here' )"]
Output if value is "here"
[/wpv-conditional]
This works fine locally. Can you try again with this syntax?
It works in my tests.
Emm, what's the difference from what I did already?
That code is what I tested locally.
Have you tried what I pasted?
Eventually you are not on a pure Author Page?
If this does not work on your side, can you confirm the issue also persists with no other Plugin and Theme Twenty Seventeen?
If so, I think I'll need a copy of your site.
https://toolset.com/faq/provide-supporters-copy-site/
Could you provide me that?
(This is in order to run some debug tools locally)