2014-05-23 331 views
3

任何人都可以幫助我在WooCommerce中創建單獨的註冊頁面,而不是在my-account頁面中顯示它嗎?WooCommerce網站的獨立註冊頁面

my-account頁面我想顯示一個鏈接,將買家帶到註冊頁面。

+0

您希望如何構建單獨的註冊頁面?一些更多的信息將會有所幫助。 – maksbd19

+0

@ maksbd19註冊頁面包含一些文本字段,如姓名,電子郵件,密碼,重新輸入密碼等。並且我的帳戶頁面僅包含登錄表單和註冊按鈕。 – Lipsa

回答

10

編輯您form-login.php文件和獨立的兩個不同部分的登錄表單,並登記表說A和B

部分現在爲您在這將確定顯示哪個部分的頁面GET參數。默認情況下,登錄將被顯示,如果參數被發現,是「註冊」,註冊顯示部分

if(isset($_GET['action']) && $_GET['action'] == "register"){ 
    // Section for registration 
}else { 
    // Section for Login form 
} 

可以爲形式-login.php中提供了一個鏈接註冊爲

<a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '?action=register"> register </a> 
1

守則

---啓動部分---

<?php 
/** 
* Login Form 
* 
* @author  WooThemes 
* @package  WooCommerce/Templates 
* @version  2.2.6 
*/ 

if (! defined('ABSPATH')) { 
    exit; // Exit if accessed directly 
} 

?> 

<?php wc_print_notices(); ?> 

<?php do_action('woocommerce_before_customer_login_form'); ?> 

<?php if (get_option('woocommerce_enable_myaccount_registration') === 'yes') : ?> 

<div class="col2-set" id="customer_login"> 

    <div class="col-1"> 

<?php endif; ?> 

     <h2><?php _e('Login', 'woocommerce'); ?></h2> 

     <form method="post" class="login"> 

      <?php do_action('woocommerce_login_form_start'); ?> 

      <p class="form-row form-row-wide"> 
       <label for="username"><?php _e('Username or email address', 'woocommerce'); ?> <span class="required">*</span></label> 
       <input type="text" class="input-text" name="username" id="username" value="<?php if (! empty($_POST['username'])) echo esc_attr($_POST['username']); ?>" /> 
      </p> 
      <p class="form-row form-row-wide"> 
       <label for="password"><?php _e('Password', 'woocommerce'); ?> <span class="required">*</span></label> 
       <input class="input-text" type="password" name="password" id="password" /> 
      </p> 

      <?php do_action('woocommerce_login_form'); ?> 

      <p class="form-row"> 
       <?php wp_nonce_field('woocommerce-login'); ?> 
       <input type="submit" class="button" name="login" value="<?php esc_attr_e('Login', 'woocommerce'); ?>" /> 
       <label for="rememberme" class="inline"> 
        <input name="rememberme" type="checkbox" id="rememberme" value="forever" /> <?php _e('Remember me', 'woocommerce'); ?> 
       </label> 
      </p> 
      <p class="lost_password"> 
       <a href="<?php echo esc_url(wp_lostpassword_url()); ?>"><?php _e('Lost your password?', 'woocommerce'); ?></a> 
      </p> 

      <?php do_action('woocommerce_login_form_end'); ?> 

     </form> 

<?php if (get_option('woocommerce_enable_myaccount_registration') === 'yes') : ?> 

    </div> 

    <div class="col-2"> 

     <h2><?php _e('Register', 'woocommerce'); ?></h2> 

     <form method="post" class="register"> 

      <?php do_action('woocommerce_register_form_start'); ?> 

      <?php if ('no' === get_option('woocommerce_registration_generate_username')) : ?> 

       <p class="form-row form-row-wide"> 
        <label for="reg_username"><?php _e('Username', 'woocommerce'); ?> <span class="required">*</span></label> 
        <input type="text" class="input-text" name="username" id="reg_username" value="<?php if (! empty($_POST['username'])) echo esc_attr($_POST['username']); ?>" /> 
       </p> 

      <?php endif; ?> 

      <p class="form-row form-row-wide"> 
       <label for="reg_email"><?php _e('Email address', 'woocommerce'); ?> <span class="required">*</span></label> 
       <input type="email" class="input-text" name="email" id="reg_email" value="<?php if (! empty($_POST['email'])) echo esc_attr($_POST['email']); ?>" /> 
      </p> 

      <?php if ('no' === get_option('woocommerce_registration_generate_password')) : ?> 

       <p class="form-row form-row-wide"> 
        <label for="reg_password"><?php _e('Password', 'woocommerce'); ?> <span class="required">*</span></label> 
        <input type="password" class="input-text" name="password" id="reg_password" /> 
       </p> 

      <?php endif; ?> 

      <!-- Spam Trap --> 
      <div style="<?php echo ((is_rtl()) ? 'right' : 'left'); ?>: -999em; position: absolute;"><label for="trap"><?php _e('Anti-spam', 'woocommerce'); ?></label><input type="text" name="email_2" id="trap" tabindex="-1" /></div> 

      <?php do_action('woocommerce_register_form'); ?> 
      <?php do_action('register_form'); ?> 

      <p class="form-row"> 
       <?php wp_nonce_field('woocommerce-register'); ?> 
       <input type="submit" class="button" name="register" value="<?php esc_attr_e('Register', 'woocommerce'); ?>" /> 
      </p> 

      <?php do_action('woocommerce_register_form_end'); ?> 

     </form> 

    </div> 

</div> 
<?php endif; ?> 

<?php do_action('woocommerce_after_customer_login_form'); ?> 

--- END SECTION ---

激起我可以把這個片斷:

---啓動部分---

if(isset($_GET['action']) && $_GET['action'] == "register"){ 
    // Section for registration 
}else { 
    // Section for Login form 
} 

---月底開始

和這個URL

--- START SECTION ---

<a href="' .get_permalink(woocommerce_get_page_id('myaccount')). '?action=register"> register </a> 

--- END SECTION ---

0

我終於想出碼具有通過在報頭中的各個鏈接單獨註冊和登錄頁面。

你需要在你的子主題編輯2個文件:

  1. functions.php
  2. form-login.php

我重視的txt文件的代碼

1)功能.php:您想要在鏈接到登錄頁面的標題中創建一個註冊鏈接,但也設置一個動作表明你已經點擊了註冊。 因此,這:

$aux_links_output .= ''. __("Login", "swiftframework") .''. "\n"; 

變成這樣:

$aux_links_output .= ''. __("Login", "swiftframework") .''. "\n"; 
$aux_links_output .= ''. __("Register", "swiftframework") .''. "\n"; 

2)形式登錄。php code: 在這裏你要創建一個if,else語句。如果你點擊註冊,然後轉到註冊頁面,否則,轉至登錄頁面:

<?php if(isset($_GET['action']) && $_GET['action'] == "register") : ?> 

科登記

<?php else : ?> 

的登錄表單部分

<?php endif; ?> 

小心的包裝材料的

謝謝