Problem:
I want to display a URL parameter (e.g., ?usr=johndoe) inside a Toolset Field & Text block, but my shortcode using get_query_var() always returns "Guest" instead of the actual value.
Solution:
Use $_GET['usr'] instead of get_query_var() in your shortcode, and sanitize it like this:
function get_usr_param() { return isset($_GET['usr']) ? sanitize_text_field($_GET['usr']) : 'Guest'; } add_shortcode('get_usr_param', 'get_usr_param');
Then use [get_usr_param] in the Field & Text block.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
This topic contains 1 reply, has 1 voice.
Last updated by 2 weeks, 3 days ago.
Assisted by: Christopher Amirian.