user_id in view

By: ali adli | Asked: 02/16/2026
ForumsCategory: Code Helpuser_id in view
ali adli asked 3 weeks ago

Hello,

In the view I have the following:

[if 483 equals="[user_id]"]<a href="/members/[482]/profil/change-avatar/">upload your profile photo</a>[/if 483]

483 is the id of the user. and I also checked that user_id works as well. But somehow this if clause fails. Any alternative or solution is greatly appreciated.

 

regards,

Ali

1 Answers
Victor Font Staff answered 3 weeks ago

Did you check your spelling? My guess is that "profil" in the url is meant to be spelled "profile"? Also, how are you constructing WordPress permalinks with user ids? If you mean to pass the url as a parameter, that's not how you do it.

ali adli
replied 3 weeks ago

Thanks for your reply Victor. Yes profil is correct. it is a translated site to Turkish. slug works that way. the problem is when I check the user_id and entry id it seems that it should work but when it comes to the if clause it fails.

Victor Font
Staff replied 3 weeks ago

That's correct. It won't work as you've written the URL. This is not how yo pass parameters to a view. This Knowledgebase article explains how to use URL parameters. https://formidableforms.com/knowledgebase/using-dynamic-default-values-in-fields/#kb-get-a-parameter-from-the-url

Victor Font
Staff replied 3 weeks ago

In your case, follow the example and your if statement should be formatted as:

[if 483 equals="[user_id]"]upload your profile photo[/if 483]

Then in your view filter, use [get param=user_id] as the user_id's value.

ali adli
replied 2 weeks ago

The link is not the problem/ The problem was the user_id inside the of statement. The reason user_id works inside a View but not directly in an if statement is related to how Formidable Forms processes and replaces those shortcodes in different contexts. In Views, the user_id is handled and replaced correctly because Views are designed to work with user data dynamically, including the current logged-in user and the user ID field values. This allows you to reference user_id and related user data easily within Views.However, in conditional shortcodes like [if ...], the user_id is not automatically recognized or replaced by Formidable Forms unless you add custom code (such as a PHP filter) to support this behavior. The if shortcode checks the raw field value, and without customization, it doesn't interpret user_id as the current user's ID.

So the solution is to set a php code:
add_filter('frmpro_fields_replace_shortcodes', 'frm_userid_shortcode1', 10, 4);
function frm_userid_shortcode1($replace_with, $tag, $atts, $field){
if(isset($atts['is_current_user'])){
global $user_ID;
if ( !$user_ID || ( $user_ID && $user_ID != $replace_with ) ) {
$replace_with = '';
}
}
return $replace_with;
}

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right