2017-07-18 2 views
1

私はemailpasswordフィールドのカスタムログインとサインアップフォームを持っています。どうすればWooCommerceのサインインと登録フォームとして使用できますか?Sign Inボタンをクリックすると、ストアのすべての商品が表示されますか?WooCommerceカスタムログインとサインアップ

global $wpdb; 
    if($_SERVER["REQUEST_METHOD"] == "POST") { 
    $username = $wpdb->escape($_REQUEST['username']); 
    $password = $wpdb->escape($_REQUEST['password']); 
    $_SESSION['username'] = $username; 
    $wpdb->get_results("select * from wp_registration where  Email='$username' AND Password='$password'"); 
    $count= $wpdb->num_rows; 
    if($count == 1) { 
    echo"<script>alert('Welcome')</script>"; 
    header('Location:index.php'); 
    } 
    else { 
    echo"<script>alert('Incorrect Username or Password!')</script>"; 
    } 
    } 
    ?> 



<input type="text" style="font-size: xx-large !important;" placeholder="Username" onfocus="this.placeholder=''" onblur="this.placeholder = 'Username'" name="username" required> 

    <input type="password" style="font-size: xx-large !important;" placeholder="password" onfocus="this.placeholder=''" onblur="this.placeholder = 'password'" name="password" required> 

    <span class="psw"><input type="submit">Submit</span> 

答えて

0
if (isset($_POST['signup'])) { 
    $username = $_POST['username']; 
    $password = $_POST['password']; 
    $creds = array(); 
    $creds['user_login'] = $username; 
    $creds['user_password'] = $password; 
    $creds['remember'] = false; 
    $user = wp_signon($creds, false); 
    if (is_wp_error($user)) { 
     echo"<script>alert('Incorrect Username or Password!')</script>"; 
    } else { 
     echo"<script>alert('Welcome')</script>"; 
     header('Location:index.php'); 
    } 
} 
?> 


<form method="post"> 
<input type="text" style="font-size: xx-large !important;" placeholder="Username" onfocus="this.placeholder=''" onblur="this.placeholder = 'Username'" name="username" required> 

    <input type="password" style="font-size: xx-large !important;" placeholder="password" onfocus="this.placeholder=''" onblur="this.placeholder = 'password'" name="password" required> 

    <span class="psw"><input name="signup" type="submit">Submit</span> 
</form> 
関連する問題