Friday, March 10, 2017

How to move (alert) sucess message for Contact Form 7 to top of form in WordPress

You can use the [response] tag in your form to change the location of the response message.

For example:


[response]

<p>Your Name (required)<br />
    [text* your-name] </p>

<p>Your Email (required)<br />
    [email* your-email] </p>

<p>Subject<br />
    [text your-subject] </p>

<p>Your Message<br />
    [textarea your-message] </p>

<p>[submit "Send"]</p>

Wednesday, March 1, 2017

How to add Password Custom field in Contact form 7.

First of all add this below code to your theme’s functions.php file.
function cfp($atts, $content = null) {
    extract(shortcode_atts(array( "id" => "", "title" => "", "pwd" => "" ), $atts));

    if(empty($id) || empty($title)) return "";

    $cf7 = do_shortcode('[contact-form-7 404 "Not Found"]');

    $pwd = explode(',', $pwd);
    foreach($pwd as $p) {
        $p = trim($p);

        $cf7 = preg_replace('/<input type="text" name="' . $p . '"/usi', '<input type="password" name="' . $p . '"', $cf7);
    }

    return $cf7;
}
add_shortcode('cfp', 'cfp');
Now we create a form with contact form 7 plugin with the following three fields: usernameemail and password
<p>Your Username (required)<br />
   [text* username] </p>

<p>Your Email (required)<br />
  [email* email] </p>

<p>Your Password<br />
  [text* password] </p>

<p>[submit "Register"]</p>
Now if we hide password field like (***) of the contact form then write following short code into your post:
[cfp id="7" title="Test" pwd="password"]