{"id":33970,"date":"2019-03-04T10:39:38","date_gmt":"2019-03-04T10:39:38","guid":{"rendered":"http:\/\/getshortcodes.com\/?post_type=docs&#038;p=33970"},"modified":"2023-02-20T14:25:04","modified_gmt":"2023-02-20T14:25:04","slug":"user-data","status":"publish","type":"docs","link":"https:\/\/getshortcodes.com\/docs\/user-data\/","title":{"rendered":"User data"},"content":{"rendered":"<div class=\"block-demo block-demo-default\">\n\t<div class=\"block-demo-viewport\">\n\t\t<p>Vova<\/p>\n\t<\/div>\n\t<div class=\"block-demo-source\">\n\t\t<pre contenteditable=\"true\"><\/pre>\n\t<\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"description\">Description<\/h2>\n\n\n\n<p>This shortcode allows you to display user data.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"options\">Options<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th>Option name<\/th><th>Possible values<\/th><th>Default value<\/th><\/tr><tr><td><strong>field<\/strong><br>User data field name. Custom meta field names are also allowed.<\/td><td>first_name (First Name)<br>last_name (Last Name)<br>nickname (Nickname)<br>description (Description)<br>locale (Locale)<br>display_name (Display name)<br>ID (ID)<br>user_login (Login)<br>user_nicename (Nice name)<br>user_url (URL)<br>user_registered (Registered)<br>user_status (Status)<\/td><td>display_name<\/td><\/tr><tr><td><strong>default<\/strong><br>This text will be shown if data is not found<\/td><td>Any text value<\/td><td><em>\u2013 none \u2013<\/em><\/td><\/tr><tr><td><strong>before<\/strong><br>This content will be shown before the value<\/td><td>Any text value<\/td><td><em>\u2013 none \u2013<\/em><\/td><\/tr><tr><td><strong>after<\/strong><br>This content will be shown after the value<\/td><td>Any text value<\/td><td><em>\u2013 none \u2013<\/em><\/td><\/tr><tr><td><strong>user_id<\/strong><br>You can specify custom user ID. Leave this field empty to use an ID of the current user<\/td><td>Any text value<\/td><td><em>\u2013 none \u2013<\/em><\/td><\/tr><tr><td><strong>filter<\/strong><br>You can apply custom filter to the retrieved value. Enter here function name. Your function must accept one argument and return modified value. Name of your function must include word filter. Example function: <br><code>function my_custom_filter( $value ) {return 'Value is: ' . $value;}<\/code><\/td><td>Any text value<\/td><td><em>\u2013 none \u2013<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"user-field-is-not-allowed\">User: field is not allowed<\/h2>\n\n\n\n<p>Since version 5.12.8 the plugin only allows you to display a set of specific user fields (see the Options table above for the full list). Any fields that are not whitelisted will trigger the &#8220;field is not allowed&#8221; error.<\/p>\n\n\n\n<p>This mechanism was introduced to improve the plugin security, since the shortcode can be used, for example, by a contributor user to access sensitive information about any user of the site.<\/p>\n\n\n\n<p>The list of allowed fields can be extended with the <code>su\/config\/user_fields<\/code> filter. To whitelist a specific field, add the code below to the end of the functions.php file of active theme. Please be careful, since the added field can be used by other writers on your site.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter( 'su\/config\/user_fields', function( $fields ) {\n\t\/\/ The field 'user_registered' will be whitelisted\n\t\/\/ and the 'User Registration Date' string will be used in the Insert Shortcode window\n\t$fields&#091;'user_registered'] = 'User Registration Date';\n\treturn $fields;\n} );<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-resized is-style-outline\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2023\/02\/Screenshot-mq4jK4j2@2x-1024x762.png\" alt=\"\" class=\"wp-image-38661\" width=\"512\" height=\"381\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2023\/02\/Screenshot-mq4jK4j2@2x-1024x762.png 1024w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2023\/02\/Screenshot-mq4jK4j2@2x-512x381.png 512w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2023\/02\/Screenshot-mq4jK4j2@2x-128x95.png 128w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2023\/02\/Screenshot-mq4jK4j2@2x-768x572.png 768w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2023\/02\/Screenshot-mq4jK4j2@2x-80x60.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2023\/02\/Screenshot-mq4jK4j2@2x-24x18.png 24w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2023\/02\/Screenshot-mq4jK4j2@2x.png 1080w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/figure>\n","protected":false},"featured_media":36668,"template":"","docs_category":[21],"class_list":["post-33970","docs","type-docs","status-publish","has-post-thumbnail","hentry","docs_category-shortcodes"],"_links":{"self":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs\/33970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/types\/docs"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/media\/36668"}],"wp:attachment":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/media?parent=33970"}],"wp:term":[{"taxonomy":"docs_category","embeddable":true,"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs_category?post=33970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}