Created
January 18, 2016 23:50
-
-
Save SErr0r/5be98dbd633ca2e60bd5 to your computer and use it in GitHub Desktop.
A login page template for WordPress.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| Template Name: Login/Logout Page | |
| */ | |
| //* Remove our default page content | |
| remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); | |
| //* Add custom login form to our page content | |
| add_action( 'genesis_entry_content', 'ck_do_login_form' ); | |
| function ck_do_login_form() { | |
| $loggedin = is_user_logged_in(); | |
| $user = wp_get_current_user(); | |
| if ( $loggedin ) { ?> | |
| <h3>You are already logged in!</h3> | |
| <p>Hello, <?php echo $user->user_firstname; ?>! Looks like you are already signed in. Thanks for being a part of this website!</p> | |
| <p><a href="/">Go to Homepage</a> or <a href="<?php echo wp_logout_url( get_permalink() ); ?>">Log Out</a></p> | |
| <?php | |
| } else { | |
| $args = array( | |
| 'form_id' => 'loginform', | |
| 'redirect' => get_bloginfo( 'url' ), | |
| 'id_username' => 'user_login', | |
| 'id_password' => 'user_pass', | |
| 'id_remember' => 'rememberme', | |
| 'id_submit' => 'wp-submit', | |
| 'label_username' => __( 'Username' ), | |
| 'label_password' => __( 'Password' ), | |
| 'label_remember' => __( 'Remember Me' ), | |
| 'label_log_in' => __( 'Log In' ), | |
| ); | |
| wp_login_form( $args ); | |
| } | |
| } | |
| genesis(); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tutorials: How to Build a Custom Login Page in Genesis