• Resolved bmontgomery

    (@bmontgomery)


    Hello,

    I’d like to know if it’s possible to have some fields required, for example like price or location ?
    If yes, could you tell me how to do ?
    I could do it by making changes to the plugin but changes would be lost when updating the plugin, so I’d like to find another way.
    Thanks for your help.

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

    (@gwin)

    Hi, you can have the location field required by adding the code below to your theme functions.php file

    
    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_location" ) {
            $form["field"][$key]["validator"] = array();
            $form["field"][$key]["validator"][] = array( "name"=> "is_required" );
        }
      }
      return $form;
    }
    

    The price field cannot be made required right now due to “money” filter it is using, which makes the price field always filled even if you submit it empty.

Viewing 1 replies (of 1 total)
  • The topic ‘Price field required’ is closed to new replies.