• Resolved kamoe

    (@kamoe)


    Fields like location and price are not obligatory as of standard with this plugin. How can I control what element of form fields are obligatory? We need location set for all ads for the ads to be organized correctly.

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

    (@gwin)

    You can do that either using Custom Fields extension or the Forms API for example the code below will make the location field required, you can add the code in 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]["validators"] = array();
            $form["field"][$key]["validators"][] = array( "name" => "is_required" );
        }
      }
      return $form;
    }
    

    See https://wpadverts.com/documentation/forms-api/ for more details.

    Thread Starter kamoe

    (@kamoe)

    Thanks.. Solved it with your addon. Very easy.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Mandatory form fields’ is closed to new replies.