Hoàng Web

Thiết kế web giá rẻ

  • Kho giao diện
  • Dịch Vụ
    • Viết bài SEO & quản trị web
    • Thiết kế website giá rẻ
    • Thiết kế website bán hàng
    • Thiết kế website WordPress
    • Viết Plugin WordPress
    • Tối ưu website WordPress
    • Sửa lỗi nâng cấp website
  • Bảng giá
  • Quy trình làm việc
  • Giới thiệu
  • Liên Lạc
Trang chủ » Wordpress » Create a custom login page for your wordpress theme

Create a custom login page for your wordpress theme

Thứ Năm, 03/07/2014 by Hoàng Quách Leave a Comment

Nội dung

  • 1 Registry form
  • 2 Recovery password form
  • 3 Display user info
  • 4 Công ty thiết kế web tại hà nội
  • Facebook
  • Twitter
  • Google+

If your site requires people to login and you’d like them to do it via your theme rather than the default WordPress login page by doing login file ( wp-login.php ) but you can create a custom login page using a page template. In this tutorial I will walk you though how to create one.
Create a page template file called ‘page-login.php’ , add this code to file, to tell wordpress that identify this file is template, place this file at root of theme folder.

<?php
/*
Template Name: Login Page
*/
?>

Include other template part such as header, footer, sidebar.

<?php get_header(); ?>
<div id="left">....[place login form]</div>
<?php get_sidebar()?>
<?php get_footer()?>

Login form code:
Next up, paste this code in which is the page title and the actual login form :

<h2><?php the_title(); ?></h2>

<form name="loginform" id="loginform" action="<?php echo get_option('home'); ?>/wp-login.php" method="post">
	<p>
		<label>Username<br />
		<input type="text" name="log" id="user_login" class="input" value="" size="20" tabindex="10" /></label>
	</p>
	<p>

		<label>Password<br />
		<input type="password" name="pwd" id="user_pass" class="input" value="" size="20" tabindex="20" /></label>
	</p>
	<p class="forgetmenot"><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90" /> Remember Me</label></p>
	<p class="submit">
		<input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="Log In" tabindex="100" />
		<input type="hidden" name="redirect_to" value="<?php echo get_option('home'); ?>/wp-admin/" />

		<input type="hidden" name="testcookie" value="1" />
	</p>
</form>

<p id="nav">
<a href="<?php echo get_option('home'); ?>/wp-login.php?action=lostpassword" title="Password Lost and Found">Lost your password?</a>
</p>

Registry form

//display message after registry success
<?php $register = $_GET['register']; if($register == true) { echo '<p>Check your email for the password!</p>'; } ?>

<!-- registration form -->
<form method="post" action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" class="wp-user-form">
	<input type="text" name="user_login" value="<?php echo esc_attr(stripslashes($user_login)); ?>" size="20" id="user_login" tabindex="101" />
	<input type="text" name="user_email" value="<?php echo esc_attr(stripslashes($user_email)); ?>" size="25" id="user_email" tabindex="102" />
	<?php do_action('register_form'); ?>
	<input type="submit" name="user-submit" value="<?php _e('Sign up!'); ?>" class="user-submit" tabindex="103" />
	<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>?register=true" />
	<input type="hidden" name="user-cookie" value="1" />
</form>

Recovery password form

//alert mesage that an email already sent to user email address.
<?php $reset = $_GET['reset']; if($reset == true) { echo '<p>A message will be sent to your email address.</p>'; } ?>
<form method="post" action="<?php echo site_url('wp-login.php?action=lostpassword', 'login_post') ?>" class="wp-user-form">
	<input type="text" name="user_login" value="" size="20" id="user_login" tabindex="1001" />
	<input type="submit" name="user-submit" value="<?php _e('Reset my password'); ?>" class="user-submit" tabindex="1002" />
	
	<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>?reset=true" />
	<input type="hidden" name="user-cookie" value="1" />
</form>

Display user info

– After login into wordpress, you must to show user info.

Công ty thiết kế web tại hà nội

Chuyên cung cấp dịch vụ thiết kế WebSite đẹp, Thân Thiện, Chuẩn SEO, Giá Cực Rẻ. Liên hệ ngay với chúng tôi để được tư vấn và hỗ trợ miễn phí. Phục vụ 24/7.

<div class="sidebox">
		<h3>Welcome, <?php echo $user_identity; ?></h3>
		<div class="usericon">
			<?php global $userdata; get_currentuserinfo(); echo get_avatar($userdata->ID, 100); ?>

		</div>
		<div class="userinfo">
			<p>You&rsquo;re logged in as <strong><?php echo $user_identity; ?></strong></p>
			<p>
				<a href="<?php echo wp_logout_url('index.php'); ?>">Log out</a> | 
				<?php if (current_user_can('manage_options')) { 
					echo '<a href="' . admin_url() . '">' . __('Admin') . '</a>'; } else { 
					echo '<a href="' . admin_url() . 'profile.php">' . __('Profile') . '</a>'; } ?>

			</p>
		</div>
	</div>

Bài viết liên quan:

  1. Creating a Custom Login Form
  2. Cách chèn file script và stylesheet trong wordpress.
  3. WordPress bị hacked và vấn đề bảo mật
  4. Tùy chỉnh cài đặt – hướng dẫn sử dụng TinyMCE [WordPress]
  5. Part 2 – Thêm custom fields cho product sử dụng advanced custom fields [woocommerce]
  6. Chống Spam Comment WordPress
  7. Tổng hợp các plugins làm slideshow images đẹp cho wordpress
  8. Hướng dẫn tạo Action và filter hooks trong wordpress
  9. Chèn file javascript css ở mọi trang trong WordPress
  10. Thêm Email Subscriptions cho WordPress Blog

Chuyên mục: Wordpress Tìm kiếm: login form, registration form

Đăng ký nhận bài viết mới

Vui lòng điền chính xác email ở bên dưới để nhận thông báo bài viết mới.

Bạn đã đăng ký thành công!

Lỗi! hãy làm lại.

thông tin của bạn được 100% bảo mật...

Lưu ý:
> Không sử dụng từ khóa trong mục "Tên".
> Hãy sử dụng tên thật và địa chỉ email chính xác.
> Vui lòng bình luận bằng tiếng Việt có dấu.
Mọi bình luận trái quy định sẽ bị gỡ bỏ link hoặc xóa bỏ hoàn toàn.

Trả lời Hủy

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

Tôi giúp gì cho bạn?

Nhận bài viết mới

Vui lòng điền chính xác email ở bên dưới để nhận thông báo bài viết mới.

Cám ơn bạn đã đăng ký.

Lỗi, hãy làm lại

thông tin của bạn được 100% bảo mật...

HOÀNG WEB

Địa chỉ: Tây Sơn, Phường Quang Trung, Quận Đống Đa, Hà Nội

Hotline: 0987 342 124 (8h:00 – 21h:00)

Email: [email protected]

Website: www.hoangweb.com

KẾT NỐI VỚI TÔI

  • Facebook
  • Snapchat

SẢN PHẨM

  • Auto-Sync WooCommerce & Google Shopping
  • Phần mềm chặn click ảo

LIÊN KẾT

  • Hướng dẫn thanh toán
  • Chính sách hoàn tiền
  • Trung tâm hỗ trợ

Copyright © 2019 | All rights reserved | HOANG WEB
Mọi hình thức sao chép nội dung trên website này mà chưa được sự đồng ý đều là trái phép.