{"id":116,"date":"2025-02-06T12:40:03","date_gmt":"2025-02-06T12:40:03","guid":{"rendered":"https:\/\/documentation.userswp.io\/article\/how-to-create-a-shortcode-to-output-the-user-id-of-any-profile-page\/"},"modified":"2025-03-27T16:37:07","modified_gmt":"2025-03-27T16:37:07","slug":"how-to-create-a-shortcode-to-output-the-user-id-of-any-profile-page","status":"publish","type":"gd_place","link":"https:\/\/userswp.io\/documentation\/article\/how-tos\/how-to-create-a-shortcode-to-output-the-user-id-of-any-profile-page\/","title":{"rendered":"How to create a shortcode to output the user ID of any profile page."},"content":{"rendered":"\n<p>Many plugins provide a shortcode to output data for a specific user and they require the user ID.<\/p>\n\n\n\n<p>If you want to add one of these shortcodes in a new tab of the users&#8217; profile pages, you&#8217;ll also need a shortcode to output the user ID for each profile page.<\/p>\n\n\n\n<p>For that, you can add the following code to a snippet using the <a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\/\">Code Snippet plugin<\/a>, or add it to your theme functions.php and finally use the shortcode\u00a0[profile_owner_ID] to output the user ID of the profile owner on any profile.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-php\">\/\/ Creating shortcode:\u00a0 [profile_owner_ID]\n\nfunction display_profile_owner_ID () {\n\u00a0 \u00a0 $user = uwp_get_displayed_user();\n\u00a0 \u00a0 return isset($user-&gt;ID) ? absint($user-&gt;ID) : &#039;&#039;;\n}\n\nadd_shortcode(&#039;profile_owner_ID&#039;, &#039;display_profile_owner_ID&#039;);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Many plugins provide a shortcode to output data for a specific user and they require the user ID. If you want to add one of these shortcodes in a new tab of the users&#8217; profile pages, you&#8217;ll also need a shortcode to output the user ID for each profile page. For that, you can add [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"article\/tags":[],"article\/categories":[41,7],"class_list":["post-116","gd_place","type-gd_place","status-publish","hentry","gd_placecategory-how-tos","gd_placecategory-tips-tricks-more"],"_links":{"self":[{"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/article\/116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/article"}],"about":[{"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/types\/gd_place"}],"author":[{"embeddable":true,"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/comments?post=116"}],"version-history":[{"count":0,"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/article\/116\/revisions"}],"wp:attachment":[{"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/media?parent=116"}],"wp:term":[{"taxonomy":"gd_place_tags","embeddable":true,"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/article\/tags?post=116"},{"taxonomy":"gd_placecategory","embeddable":true,"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/article\/categories?post=116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}