• Resolved alexrick

    (@alexrick)


    Hi Greg
    Thanks for your support
    The view is damaged in grid, when someone creates an ad and does not place a location (city or country) How to make the mandatory location or what alternative do I have about it?
     

    The page I need help with: [log in to see the link]

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

    (@gwin)

    Hi,
    you can make the location required by adding the code below in your theme functions.php file

    
    add_filter( "adverts_form_load", "require_location_adverts_add" );
    function require_location_adverts_add( $form ) {
      if( $form['name'] != "advert" ) {
        return $form;
      }
      foreach( $form["field"] as $key => $field ) {
        if( $field["name"] == "adverts_location" ) {
            $form["field"][$key]["is_required"] = true;
            $form["field"][$key]["validator"][] = array( "name" => "is_required" )
        }
      }
      return $form;
    }
    
    Thread Starter alexrick

    (@alexrick)

    When trying to add the code I get the following error:

    Los cambios en tu código PHP se han revertido debido a un error en la línea 9690 del archivo wp-content/themes/Divi/functions.php. Por favor, arréglalo y trata de guardar de nuevo.

    syntax error, unexpected ‘}’

    The error is in this line ⇨⇨⇨ }
    }
    return $form;
    }

    Plugin Author Greg Winiarski

    (@gwin)

    In the code change array( "name" => "is_required" ) to array( "name" => "is_required" );

    Thread Starter alexrick

    (@alexrick)

    it works thank you

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Mandatory location’ is closed to new replies.