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

    (@gwin)

    Hi, you can make email field not required by adding code below to your theme functions.php

    add_filter( "adverts_form_load", "customize_adverts_add" );
    
    function customize_adverts_add( $form ) {
      if( $form['name'] != "advert" ) {
        return $form;
      }
    
      foreach( $form["field"] as $key => $field ) {
        if( $field["name"] == "adverts_email" ) {
            $field["validator"] = array( array( "name" => "is_email" ) );
        }
      }
    
      return $form;
    }

    Note, that the plugin will most likely break if user will decide he wants to register an account but will not enter his email address.

    Thread Starter joelcdmedia

    (@joelcdmedia)

    This didn’t work unfortunately.

    Tried adding it to Theme and Child Theme.

    Still have the ‘Post updated, but cannot be published since some required data is not filled properly’ error.

    Any other ideas? Thanks ??

    Plugin Author Greg Winiarski

    (@gwin)

    There is one missing line in the code, try this instead

    add_filter( "adverts_form_load", "customize_adverts_add" );
    
    function customize_adverts_add( $form ) {
      if( $form['name'] != "advert" ) {
        return $form;
      }
    
      foreach( $form["field"] as $key => $field ) {
        if( $field["name"] == "adverts_email" ) {
            $field["validator"] = array( array( "name" => "is_email" ) );
            $form["field"][$key] = $field;
        }
      }
    
      return $form;
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Required email update?’ is closed to new replies.