{"id":2174,"date":"2021-07-13T06:55:24","date_gmt":"2021-07-12T22:55:24","guid":{"rendered":"https:\/\/www.intelliwolf.com\/?p=2174"},"modified":"2021-07-13T06:55:27","modified_gmt":"2021-07-12T22:55:27","slug":"get-wordpress-user-display-name","status":"publish","type":"post","link":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/get-wordpress-user-display-name\/","title":{"rendered":"How To Get WordPress User Display Name"},"content":{"rendered":"\n

There are times when you want to personalise a user's experience, perhaps in a membership site or in a marketplace style site. In those cases, it's handy to be able to display a users name.<\/p>\n\n\n\n

You probably don't want to display the actual usernames, especially when WordPress provides a way for people to customize how they are seen on the site.<\/p>\n\n\n\n

To get a WordPress user's display name, you need to get the user object, then use $user->display_name<\/em> to access the user's name.<\/strong><\/p>\n\n\n\n

That will display whatever the user has set as their display name in this field:<\/p>\n\n\n\n

\"screenshot<\/figure><\/div>\n\n\n\n

If the user hasn't specifically set anything as their display name, it will default to their username. So you don't have to worry about fallbacks.<\/p>\n\n\n\n

This is saved in the wp_users<\/em> table under display_name<\/em> for the particular user.<\/p>\n\n\n\n

How to get the User object<\/h2>\n\n\n\n

There are a few ways to access the WordPress User object, depending on what information you have.<\/p>\n\n\n\n

If you just want to display the current user's name, use wp_get_current_user()<\/em>. This will only work for the currently logged in user.<\/p>\n\n\n\n

$user = wp_get_current_user();<\/code><\/pre>\n\n\n\n

If you have an ID of a specific user who may or may not be logged in, or you're looping through a list of IDs, my preferred way is:<\/p>\n\n\n\n

$user = get_userdata( $user_id );<\/code><\/pre>\n\n\n\n

If you have some other information for the user, maybe an email or a username, use:<\/p>\n\n\n\n

$user = get_user_by( 'email', 'user@domain.com' );<\/code><\/pre>\n\n\n\n

Change the fields according to what information you have.<\/p>\n\n\n\n

<\/p>\n","protected":false},"excerpt":{"rendered":"

There are times when you want to personalise a user’s experience, perhaps in a membership site or in a marketplace style site. In those cases, it’s handy to be able to display a users name. You probably don’t want to display the actual usernames, especially when WordPress provides a way for people to customize how<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"yoast_head":"\nHow To Get WordPress User Display Name<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Get WordPress User Display Name\" \/>\n<meta property=\"og:description\" content=\"There are times when you want to personalise a user's experience, perhaps in a membership site or in a marketplace style site. In those cases, it's handy to be able to display a users name. You probably don't want to display the actual usernames, especially when WordPress provides a way for people to customize how\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/\" \/>\n<meta property=\"og:site_name\" content=\"Intelliwolf\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-12T22:55:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-07-12T22:55:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/07\/2021-07-13-user-display-name-600x262.png\" \/>\n<meta name=\"author\" content=\"Mike Haydon\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mike Haydon\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/\"},\"author\":{\"name\":\"Mike Haydon\",\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/person\/7209e3ff14822e4d70d5f194a310f343\"},\"headline\":\"How To Get WordPress User Display Name\",\"datePublished\":\"2021-07-12T22:55:24+00:00\",\"dateModified\":\"2021-07-12T22:55:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/\"},\"wordCount\":249,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.intelliwolf.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/07\/2021-07-13-user-display-name-600x262.png\",\"articleSection\":[\"General\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/\",\"url\":\"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/\",\"name\":\"How To Get WordPress User Display Name\",\"isPartOf\":{\"@id\":\"https:\/\/www.intelliwolf.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/07\/2021-07-13-user-display-name-600x262.png\",\"datePublished\":\"2021-07-12T22:55:24+00:00\",\"dateModified\":\"2021-07-12T22:55:27+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/#primaryimage\",\"url\":\"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/2021\/07\/2021-07-13-user-display-name.png\",\"contentUrl\":\"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/2021\/07\/2021-07-13-user-display-name.png\",\"width\":778,\"height\":340},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.intelliwolf.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"General\",\"item\":\"https:\/\/www.intelliwolf.com\/category\/general\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How To Get WordPress User Display Name\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.intelliwolf.com\/#website\",\"url\":\"https:\/\/www.intelliwolf.com\/\",\"name\":\"Intelliwolf\",\"description\":\"WordPress, Web Design and Coding Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.intelliwolf.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.intelliwolf.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.intelliwolf.com\/#organization\",\"name\":\"Intelliwolf\",\"url\":\"https:\/\/www.intelliwolf.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/intelliwolf-logo-300t.png\",\"contentUrl\":\"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/intelliwolf-logo-300t.png\",\"width\":300,\"height\":100,\"caption\":\"Intelliwolf\"},\"image\":{\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/person\/7209e3ff14822e4d70d5f194a310f343\",\"name\":\"Mike Haydon\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d5f4754fae310a04dede91d15e57c8a0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d5f4754fae310a04dede91d15e57c8a0?s=96&d=mm&r=g\",\"caption\":\"Mike Haydon\"},\"sameAs\":[\"https:\/\/intelliwolf.com\/about-mike-haydon\/\"]}]}<\/script>\n","yoast_head_json":{"title":"How To Get WordPress User Display Name","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/","og_locale":"en_US","og_type":"article","og_title":"How To Get WordPress User Display Name","og_description":"There are times when you want to personalise a user's experience, perhaps in a membership site or in a marketplace style site. In those cases, it's handy to be able to display a users name. You probably don't want to display the actual usernames, especially when WordPress provides a way for people to customize how","og_url":"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/","og_site_name":"Intelliwolf","article_published_time":"2021-07-12T22:55:24+00:00","article_modified_time":"2021-07-12T22:55:27+00:00","og_image":[{"url":"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/07\/2021-07-13-user-display-name-600x262.png"}],"author":"Mike Haydon","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Mike Haydon","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/#article","isPartOf":{"@id":"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/"},"author":{"name":"Mike Haydon","@id":"https:\/\/www.intelliwolf.com\/#\/schema\/person\/7209e3ff14822e4d70d5f194a310f343"},"headline":"How To Get WordPress User Display Name","datePublished":"2021-07-12T22:55:24+00:00","dateModified":"2021-07-12T22:55:27+00:00","mainEntityOfPage":{"@id":"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/"},"wordCount":249,"commentCount":0,"publisher":{"@id":"https:\/\/www.intelliwolf.com\/#organization"},"image":{"@id":"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/#primaryimage"},"thumbnailUrl":"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/07\/2021-07-13-user-display-name-600x262.png","articleSection":["General"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/","url":"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/","name":"How To Get WordPress User Display Name","isPartOf":{"@id":"https:\/\/www.intelliwolf.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/#primaryimage"},"image":{"@id":"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/#primaryimage"},"thumbnailUrl":"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/07\/2021-07-13-user-display-name-600x262.png","datePublished":"2021-07-12T22:55:24+00:00","dateModified":"2021-07-12T22:55:27+00:00","breadcrumb":{"@id":"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/#primaryimage","url":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/2021\/07\/2021-07-13-user-display-name.png","contentUrl":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/2021\/07\/2021-07-13-user-display-name.png","width":778,"height":340},{"@type":"BreadcrumbList","@id":"https:\/\/www.intelliwolf.com\/get-wordpress-user-display-name\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.intelliwolf.com\/"},{"@type":"ListItem","position":2,"name":"General","item":"https:\/\/www.intelliwolf.com\/category\/general\/"},{"@type":"ListItem","position":3,"name":"How To Get WordPress User Display Name"}]},{"@type":"WebSite","@id":"https:\/\/www.intelliwolf.com\/#website","url":"https:\/\/www.intelliwolf.com\/","name":"Intelliwolf","description":"WordPress, Web Design and Coding Tutorials","publisher":{"@id":"https:\/\/www.intelliwolf.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.intelliwolf.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.intelliwolf.com\/#organization","name":"Intelliwolf","url":"https:\/\/www.intelliwolf.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.intelliwolf.com\/#\/schema\/logo\/image\/","url":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/intelliwolf-logo-300t.png","contentUrl":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/intelliwolf-logo-300t.png","width":300,"height":100,"caption":"Intelliwolf"},"image":{"@id":"https:\/\/www.intelliwolf.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.intelliwolf.com\/#\/schema\/person\/7209e3ff14822e4d70d5f194a310f343","name":"Mike Haydon","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.intelliwolf.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d5f4754fae310a04dede91d15e57c8a0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d5f4754fae310a04dede91d15e57c8a0?s=96&d=mm&r=g","caption":"Mike Haydon"},"sameAs":["https:\/\/intelliwolf.com\/about-mike-haydon\/"]}]}},"_links":{"self":[{"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/posts\/2174"}],"collection":[{"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/comments?post=2174"}],"version-history":[{"count":2,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/posts\/2174\/revisions"}],"predecessor-version":[{"id":2255,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/posts\/2174\/revisions\/2255"}],"wp:attachment":[{"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/media?parent=2174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/categories?post=2174"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/tags?post=2174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}