WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Have I used is_email() correctly for this email field?

[Resolved] Have I used is_email() correctly for this email field?

  • Hello,

    I’m building my first widget. I need to add an email field to my widget, is this correct please? Should I use is_email() ?

    function update($new_instance, $old_instance) {
         $instance = $old_instance;
         $instance['email'] = is_email($new_instance['email']);
    
        return $instance;
         }

    And

    function form($instance) {
    
         $email = sanitize_email($instance['email']);
              ?>
    
     <p>
        <label for="<?php echo  $this->get_field_id('email'); ?>">
         <?php _e('Email'); ?>  </label>
         <input class="widefat" id="<?php echo $this->get_field_id('email'); ?>" name="<?php echo $this->get_field_name('email'); ?>" type="email" value="<?php echo $email; ?> " />
        </p>
        <?php
        }

    Please can someone advise? I would really appreciate some help. Thanks

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Have I used is_email() correctly for this email field?’ is closed to new replies.