• Resolved nagahxp

    (@nagahxp)


    Greetings

    I need two things with email field while creating new ad or listing
    – I want to make either phone or email to be required as most of the users prefer phone contacts in my area
    – for email field it will be better if we can auto delete extra spaces before or after the email address when clicking review ad, as most of users are getting extra space after email address when clicking the auto-fill option which is giving unacceptable email address.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    the email field is always required, you should never make it optional as this will cause some unexpected behavior, for example, if the user will check the “Create an account for me …” checkbox in the [adverts_add].

    The extra spaces from the email address you can remove by adding the code below in your theme functions.php file

    
    add_filter( "adverts_form_load", "customize_adverts_add_10638879" );
    function customize_adverts_add_10638879( $form ) {
      if( $form['name'] != "advert" ) {
        return $form;
      }
      foreach( $form["field"] as $key => $field ) {
        if( $field["name"] == "adverts_email" ) {
          adverts_form_add_filter("my_trim", array(
            "description" => "Trim whitespaces",
            "callback" => "my_trim_filter"
          ));
          $form["field"][$key]["filter"] = array( array( "name" => "my_trim" ) );
        }
      }
      return $form;
    }
    function my_trim_filter( $data ) {
        return trim( $data );
    }
    
    Thread Starter nagahxp

    (@nagahxp)

    Hi

    thanks for that, it works as required
    and thanks for your prompt responses

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add listing email field’ is closed to new replies.