1

I am developing a WordPress plugin. In this regard I am gathering data from User using a Form via Wordpress Admin Panel. My code is like below

<form method="post" name="newAddress" id="newAddress" class="validate" novalidate="novalidate">
    <table class="form-table" role="presentation">
      <tr class="form-field form-required">
        <th scope="row">
          <label for="name">
            <?php _e( 'Name' ); ?>
          </label>
        </th>
        <td>
          <input name="name" type="text" id="name" value="<?php echo esc_attr( $new_user_login ); ?>" aria-required="true" autocapitalize="none" autocorrect="off" maxlength="60" />
        </td>
      </tr>
      <tr class="form-field form-required">
        <th scope="row">
          <label for="email">
            <?php _e( 'Email' ); ?>
          </label>
        </th>
        <td>
          <input name="email" type="email" id="email" value="<?php echo esc_attr( $new_user_email ); ?>" />
        </td>
      </tr>
      <tr class="form-field">
        <th scope="row">
          <label for="phone_no">
            <?php _e( 'Phone No' ); ?> 
          </label>
        </th>
        <td>
          <input name="phone_no" type="text" id="phone_no" value="<?php echo esc_attr( $new_user_firstname ); ?>" />
        </td>
      </tr>
      <tr class="form-field">
        <th scope="row">
          <label for="address">
            <?php _e( 'Address' ); ?> 
          </label>
        </th>
        <td>
          <input name="address" type="text" id="address" value="<?php echo esc_attr( $new_user_lastname ); ?>" />
        </td>
      </tr>
      <tr class="form-field">
        <th scope="row">
          <label for="photo">
            <?php _e( 'Photo' ); ?>
          </label>
        </th>
        <td>
          <input name="photo" type="text" id="photo" class="code" value="<?php echo esc_attr( $new_user_uri ); ?>" />
        </td>
      </tr>
    </table>
    <?php submit_button( __( 'Add New Address' ), 'primary', 'newAddress', true, array( 'id' => 'newAddress' ) ); ?>
  </form> 

My Form looks like below

enter image description here

How can I add Form validation here ?

3
  • 1
    Fyi, second parameter of the _e() and __() functions is textdomain. Without textdomain your plugin will work but your plugin needs to follow the standard if you like to submit the plugin in WordPress repository.
    – Shah Alom
    Nov 15, 2019 at 16:06
  • Thank you @ShahAlom vai. Could you please explain more ?
    – Foysal
    Nov 15, 2019 at 17:11

1 Answer 1

2

Data Sanitization in Wordpress ... https://developer.wordpress.org/themes/theme-security/data-sanitization-escaping/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.