Skip to content

Instantly share code, notes, and snippets.

Last active February 27, 2019 16:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
[WordPress] Use the Current User ID with Pods
[pods-form name="user" fields="first_name, last_name" where="current_user_id = user_id" label="Update"]
add_filter('the_content', __NAMESPACE__ . '\\filter_pods_by_current_user');
* Replaces the current_user_id = user_id with the current user ID in the
* incoming content (which includes the Pods shortcode).
* @param string $content the content of the shortcode.
* @return string the result of the parsed shortcode.
function filter_pods_by_current_user($content)
$user = wp_get_current_user();
return str_ireplace(
'current_user_id = user_id',
"id='" . $user->ID . "'",
[pods-form name="user" fields="first_name, last_name" where="id = 100" label="Update"]
Copy link

There should be an is_user_logged_in() check here.

Also, the below is available if you set this in wp-config.php define( 'PODS_SHORTCODE_ALLOW_EVALUATE_TAGS', true );

[pods-form name="user" fields="first_name,last_name" id="{@user.ID}" label="Update"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment