2017-09-08 12 views
-2

プラグインを使用せずに、最初から作成するか、WP登録フォームを変更するにはどうすればよいですか? ウェブで訴訟を見つけることができません。すべてのプラグインで。事前WPカスタム登録フォーム

+0

このトピックはオフトピックです:[ここで私は何についてお聞きしますか?](https://stackoverflow.com/help/on-topic)を参照してください。 ***あなたの問題を調査し、投稿する前に自分でコードを書き込もうとしました***。 *具体的な質問がある場合は、これまでに試したことの詳細と[最小限の、完全で検証可能な例](https://stackoverflow.com/help/mcve)が含まれている必要があります。 [Stack Overflowユーザーの研究努力の程度](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users)をお読みください。 – FluffyKitten

答えて

0

おかげで、私は通常、カスタムの連絡先フォームを作ることができるようにゼロからプラグインを作成する - 参照:https://codex.wordpress.org/Writing_a_Plugin

あなたのプラグインは、すなわち、フォームを表示する必要があります。

<form id="myform" method="post" action="contact_form.php"> 
    <input type="text" name="first_name" /> 
    <input type="text" name="last_name" /> 
    <textarea rows="10" name="message" /> 
    <input type="submit" value="Submit" /> 
</form> 

そしてあなた

contact_fで私は、これはあなたを助けるために管理して期待し

$first = $_POST['first_name']; 
$last = $_POST['last_name']; 
$message = $_POST['message']; 

$email = "Name: " . $first . " Last name: " . $last . " Message: " . $message; 

$to = "[email protected]"; 
$subject = "New message from " . $first . " " . $last; 
$body = $email; 
$headers = array('Content-Type: text/html; charset=UTF-8'); 

wp_mail($to, $subject, $body, $headers); 

:orm.php

は次のように何かをします!

WPプラグインを構築する方法を学ぶことで、将来的に大いに役立ちます。そのため、WPドキュメントに潜む価値がありますので、その対象に関する幅広い知識を得ることができます。運が良かった! :-)

0
add_action('register_form', 'myplugin_register_form'); 
function myplugin_register_form() { 

    $first_name = (! empty($_POST['first_name'])) ? trim($_POST['first_name']) : ''; 

     ?> 
     <p> 
      <label for="first_name"><?php _e('First Name', 'mydomain') ?><br /> 
       <input type="text" name="first_name" id="first_name" class="input" value="<?php echo esc_attr(wp_unslash($first_name)); ?>" size="25" /></label> 
     </p> 
     <?php 
    } 

    //2. Add validation. In this case, we make sure first_name is required. 
    add_filter('registration_errors', 'myplugin_registration_errors', 10, 3); 
    function myplugin_registration_errors($errors, $sanitized_user_login, $user_email) { 

     if (empty($_POST['first_name']) || ! empty($_POST['first_name']) && trim($_POST['first_name']) == '') { 
      $errors->add('first_name_error', __('<strong>ERROR</strong>: You must include a first name.', 'mydomain')); 
     } 

     return $errors; 
    } 

    //3. Finally, save our extra registration user meta. 
    add_action('user_register', 'myplugin_user_register'); 
    function myplugin_user_register($user_id) { 
     if (! empty($_POST['first_name'])) { 
      update_user_meta($user_id, 'first_name', trim($_POST['first_name'])); 
     } 
    }