{"id":118,"date":"2025-02-06T12:40:03","date_gmt":"2025-02-06T12:40:03","guid":{"rendered":"https:\/\/documentation.userswp.io\/article\/how-to-change-the-username-placeholder-on-login-forms\/"},"modified":"2025-03-27T16:35:17","modified_gmt":"2025-03-27T16:35:17","slug":"how-to-change-the-username-placeholder-on-login-forms","status":"publish","type":"gd_place","link":"https:\/\/userswp.io\/documentation\/article\/code-snippets\/how-to-change-the-username-placeholder-on-login-forms\/","title":{"rendered":"How to Change the Username Placeholder on Login Forms?"},"content":{"rendered":"\n<p>By default, UsersWP lets users login via their email address or their chosen username. This is in sync with the native WordPress behavior. However, if you prefer, you can choose to replace the &#8220;username&#8221; placeholder on your login forms, and replace it with &#8220;email&#8221;.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Replace the &#8220;Username&#8221; Placeholder Text?&nbsp;<\/h2>\n\n\n\n<p>To accomplish this, simply use the following code snippet:&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-php\">add_filter(&#039;uwp_get_field_placeholder&#039;, &#039;uwp_get_field_placeholder_cb&#039;, 10, 2); \n\nfunction uwp_get_field_placeholder_cb($placeholder, $field){    \n\tif(isset($field) &amp;&amp; isset( $field-&gt;form_type ) &amp;&amp; $field-&gt;form_type == &#039;login&#039; &amp;&amp; $field-&gt;htmlvar_name == &#039;username&#039; ){         \n\t\t$placeholder = __( &quot;Email&quot;, &#039;userswp&#039; );         \n\t\tif ( isset( $field-&gt;is_required ) &amp;&amp; ! empty( $field-&gt;is_required ) ) { \t\t  \n\t\t$placeholder .= &#039; *&#039;; \t   \n\t\t}    \n\t}      \n\treturn $placeholder; \n}<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-blockstrap-blockstrap-widget-alert d-flex align-items-center fade show alert alert-info mb-3\" role=\"alert\"><span class=\"fas fa-info-circle me-2\"><\/span><span class=\"flex-grow-1\">We recommend using the <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/useful-plugins\/code-snippets-plugin\/\" target=\"_blank\">Code Snippets<\/a> plugin to add snippets to your site.<\/span><\/div>\n\n\n\n<p>In case the above code does not work, try deleting your site&#8217;s cache. That will ensure that the page loads afresh and the code snippet will start working.&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By default, UsersWP lets users login via their email address or their chosen username. This is in sync with the native WordPress behavior. However, if you prefer, you can choose to replace the &#8220;username&#8221; placeholder on your login forms, and replace it with &#8220;email&#8221;.&nbsp; How to Replace the &#8220;Username&#8221; Placeholder Text?&nbsp; To accomplish this, simply [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"article\/tags":[88,175,176,177],"article\/categories":[40,7],"class_list":["post-118","gd_place","type-gd_place","status-publish","hentry","gd_place_tags-login-form","gd_place_tags-username","gd_place_tags-email","gd_place_tags-custom-code","gd_placecategory-code-snippets","gd_placecategory-tips-tricks-more"],"_links":{"self":[{"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/article\/118","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=118"}],"version-history":[{"count":0,"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/article\/118\/revisions"}],"wp:attachment":[{"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/media?parent=118"}],"wp:term":[{"taxonomy":"gd_place_tags","embeddable":true,"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/article\/tags?post=118"},{"taxonomy":"gd_placecategory","embeddable":true,"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/article\/categories?post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}