{"componentChunkName":"component---src-pages-markdown-remark-fields-slug-js","path":"/engineering/part-2-creating-a-custom-login-form/","result":{"data":{"markdownRemark":{"id":"da619579-7270-565c-9e4a-1464a5bae851","excerpt":"In this tutorial I will demonstrate how to build a custom login form scratch. This time instead of using the default function call Wordpress provides us, we…","html":"<p>In this tutorial I will demonstrate how to build a custom login form scratch. This time instead of using the default function call Wordpress provides us, we will create this login form and the styling from scratch, making it a very customized form. I will be providing the CSS I am using, however you may style this however you wish.</p>\n<h2 id=\"building-a-custom-login-form\" style=\"position:relative;\"><a href=\"#building-a-custom-login-form\" aria-label=\"building a custom login form permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Building a Custom Login Form</h2>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 574px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 79.79094076655052%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAIAAACZeshMAAAACXBIWXMAAAsTAAALEwEAmpwYAAACqUlEQVQoz3WT+0/TUBTH9zf5s3+C/uoP/qI/GcXEGEw0RoOGRQQEnYowg6hBTciiJC5KFCW8ApOBymMPxrpH6R5tt/be3tt7uz7Weruhos6Tkyb3tJ/z7TnnnoD2f6MYGTrWoAahfwRAU1XInmYDER2xYKAjBlvkyHzq4uuNiqz6GVo8w3SMou/LsXXJoOgAZu9YygMFCJngDi+dm4qffL4SXtjVFISwVqmCuYVqLC6duZC60pMBbWXG6DpqOpgSBABkUaRp+2J9eDYZ/LQ1OcstLolM80bf3u1hrncge38sf/5SWiipAUYSggq8Gp0pc3mFUl3TECHYMommo69JKZdV1zakdEYJDnCR6f3vW7IkweBgVigDH8YYhUbzE5PF/ntcOoM9z6vVGwBagmBcu8nt5Ug6ow89KOSLdHScn1uo9PZnI9NCw0ABhFi1sG+YW1oVRx7nhx7mKizxQLbvbuFlpNLVvatqlut5K3EgVI13H+UXU/x2osZIVm9bWSuV1a7u1OmzydAYz/ztjLyZ0B6N8+Gn++vfgOc1Lcumpu00bdfVKUUQ+K0NtAYIHVv/si6GJ4Rnr0rT0dLok2LwTm5+WWm67nYSQWSzWj7M1Y+f2Pw8XzUMDH7B7W4XimpwkIu8KVPWQETlmsGAxWXlyNG1WJyJe7xAwhN+w9hQ2kP9fUlY8bbFALfZ9J2Z7TgAmrG4iglTdqlqEt20bUz+hSGEhFLTtAmhhDYIMRzHcVmvPC+xh0/1pI5dT9wK5QdDuWxO+ft6MphS6rmu5ZttmRbTZ6SqWpd7s1ejfGhLxKa5siruJGt+zzrAh6wtqwIrkcbtiOPYloU6/PahLD+Xo7VPbBMoxXVFU/w48hcLHnz5B4wQqss1sSrWanVZkplLoiSLsqKAjsv3AxaRT4JDSnKaAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"wp-login-boring\"\n        title=\"wp-login-boring\"\n        src=\"/static/e6f31dc6cf2ee195c1d37e9a67322d0c/86389/wp-login-boring.png\"\n        srcset=\"/static/e6f31dc6cf2ee195c1d37e9a67322d0c/86389/wp-login-boring.png 574w\"\n        sizes=\"(max-width: 574px) 100vw, 574px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></p>\n<p>This is what WordPress gives us out of the box.. Boring, right?</p>\n<p>I am going to show this part once again because it is probably the easiest to implement for beginners. I covered this in Part 1, but we'll go through it again just in case you're skipping ahead</p>\n<p>To start our page theme you will need to do the following</p>\n<p>1. Install WordPress\n2. Navigate to your wp-content/themes folder and choose a theme to edit or install a new one\n3. create a file called page-login-custom.php in the theme directory (Notice we are now making a new Page Theme)\n4. Next open that file with a text editor of your choosing and add the following at the top of the php file</p>\n<p>--></p>\n<p>To initialize this page template make sure to activate the theme you've selected and then navigate to a page or post. On the right hand side of your page/post editor you should now see a dropdown available for template. Change your template to Login Custom and that will attach that page theme to this page/post.</p>\n<p>Now for the custom code. Below I have provided an example of some code that I have customized to make my custom login form.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"js\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">form</span><span class=\"mtk1\"> </span><span class=\"mtk12\">method</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;post&quot;</span><span class=\"mtk1\"> </span><span class=\"mtk12\">action</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;&quot;</span><span class=\"mtk1\"> </span><span class=\"mtk12\">class</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;wp-user-form&quot;</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">input</span><span class=\"mtk1\"> </span><span class=\"mtk12\">type</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;text&quot;</span><span class=\"mtk1\"> </span><span class=\"mtk12\">name</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;log&quot;</span><span class=\"mtk1\"> </span><span class=\"mtk12\">value</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;&quot;</span><span class=\"mtk1\"> </span><span class=\"mtk12\">size</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;20&quot;</span><span class=\"mtk1\"> </span><span class=\"mtk12\">id</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;user_login&quot;</span><span class=\"mtk1\"> </span><span class=\"mtk12\">tabindex</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;11&quot;</span><span class=\"mtk1\"> </span><span class=\"mtk17\">/&gt;</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">:</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">Remember me</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">input</span><span class=\"mtk1\"> </span><span class=\"mtk12\">type</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;submit&quot;</span><span class=\"mtk1\"> </span><span class=\"mtk12\">name</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;user-submit&quot;</span><span class=\"mtk1\"> </span><span class=\"mtk12\">value</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;&quot;</span><span class=\"mtk1\"> </span><span class=\"mtk12\">tabindex</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;14&quot;</span><span class=\"mtk1\"> </span><span class=\"mtk12\">class</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;user-submit&quot;</span><span class=\"mtk1\"> </span><span class=\"mtk17\">/&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">input</span><span class=\"mtk1\"> </span><span class=\"mtk12\">type</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;hidden&quot;</span><span class=\"mtk1\"> </span><span class=\"mtk12\">name</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;redirect_to&quot;</span><span class=\"mtk1\"> </span><span class=\"mtk12\">value</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;&quot;</span><span class=\"mtk1\"> </span><span class=\"mtk17\">/&gt;</span></span></code></pre>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 743px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 30.153846153846153%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAIAAABM9SnKAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAUklEQVQY053PSw6AMAhAQe5/Vpu0hM9CW6xF3WBjdLbkBQC7tMGCNgd9rKoi4mUNbO6IETGX4vEaPJ5zxn2WByLaao23vWxOaWFmf8++gB/NbQe5NGSblvZQtAAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"login-2-custom\"\n        title=\"login-2-custom\"\n        src=\"/static/4fa351920dfdb37fdbc4cac1f740f52e/f2793/login-2-custom.png\"\n        srcset=\"/static/4fa351920dfdb37fdbc4cac1f740f52e/a6d36/login-2-custom.png 650w,\n/static/4fa351920dfdb37fdbc4cac1f740f52e/f2793/login-2-custom.png 743w\"\n        sizes=\"(max-width: 743px) 100vw, 743px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></p>\n<p>Let's take a look at that custom form</p>\n<h2 id=\"handling-the-login-form-response\" style=\"position:relative;\"><a href=\"#handling-the-login-form-response\" aria-label=\"handling the login form response permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Handling the Login Form response</h2>\n<p>To handle the Login Form response use the exact same method we used in part 1. Remember to place that function within your functions.php file within your theme unless you're building a plugin.</p>\n<p>In this example we have built a custom WordPress login form that you could customize and style to your desire. In the next section I will be demonstrating how to build a lost password form that is fully customized. Our custom lost password form will send an email to the user as well as handle creating a new password for the user.</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n  .dark-default-dark {\n    background-color: #1E1E1E;\n    color: #D4D4D4;\n  }\n  .dark-default-dark .mtk17 { color: #808080; }\n  .dark-default-dark .mtk4 { color: #569CD6; }\n  .dark-default-dark .mtk1 { color: #D4D4D4; }\n  .dark-default-dark .mtk12 { color: #9CDCFE; }\n  .dark-default-dark .mtk8 { color: #CE9178; }\n</style>","headings":[{"value":"Building a Custom Login Form","depth":2},{"value":"Handling the Login Form response","depth":2}],"fields":{"slug":"/engineering/part-2-creating-a-custom-login-form/"},"frontmatter":{"metatitle":null,"metadescription":null,"description":null,"title":"Part 2 - Creating a Custom Login Form","canonical":null,"date":"December 08, 2015","updated_date":null,"tags":["Engineering","Login"],"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1,"src":"/static/3e9f0e12bae5ff4eea3aa1dae7083c47/d399c/cust-login-2-150x150.png","srcSet":"/static/3e9f0e12bae5ff4eea3aa1dae7083c47/d399c/cust-login-2-150x150.png 150w","sizes":"(max-width: 150px) 100vw, 150px"}}},"author":{"id":"Zoie Carnegie","github":null,"bio":"Graduated from NAIT Digital Media and IT specializing in application development. PHP is my favorite language. I am a continuous learner always trying new languages, applications, frameworks. Passions are Programming, Photography and Travel.","avatar":null}}}},"pageContext":{"id":"da619579-7270-565c-9e4a-1464a5bae851","fields__slug":"/engineering/part-2-creating-a-custom-login-form/","__params":{"fields__slug":"engineering"}}},"staticQueryHashes":["1171199041","1384082988","1711371485","1753898100","2100481360","229320306","23180105","528864852"]}