First, enable Dynamic Features in Pods Admin > Settings > Security section so that the block WHERE
field displays.
Option 1:
- Use magic tags by adding
define( 'PODS_SHORTCODE_ALLOW_EVALUATE_TAGS', true );
to wp-config.php
- Use
{@user.ID} IN( custom_field_name.ID )
for the WHERE query, meaning the current user ID is found in a field named custom_field_name
on the queried pod, which would be a relationship field connected to users.
Option 2:
If channging wp-config.php is challenging or the magic tag {@user.ID}
does not work as expected, add this PHP code snippet with a plugin like Code Snippets:
add_filter(
'pods_pods_find',
function( $params ) {
$params = (array) $params;
if ( array_key_exists( 'where', $params ) ) {
$params['where'] = str_replace(
'CURRENTUSERID',
get_current_user_id(),
(string) $params['where']
);
}
return (object) $params;
}
);
Then use CURRENTUSERID IN( custom_field_name.ID )
as the WHERE query, with the same custom_field_name.ID
assumption as above.
I see, it still doesn’t work. I have a custom field called achiever (it’s a relation field to user) but the magic tags for achiever doesn’t show up on pod templates. is it the problem?
Apologies for the delayed follow-up.
If {@achiever}
and [each achiever]{@user_login}[/each]
don’t display anything in the templates, make sure the Pod Block or shortcode is querying the post type certificate
The code provided previously was for modifying the WHERE
field on the Block, which displays if SQL is enabled in Pods Admin > Settings
If it’s still challenging, please open a new ticket with more details about the setup or join the support chat on Slack using the link at support.pods.io