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

    (@gwin)

    You can do this by adding following code in your theme functions.php

    add_filter( "adverts_form_load", "my_adverts_form_require_category" );
    function my_adverts_form_require_category( $form ) {
        if($form["name"] != "advert") {
            return $form;
        }
    
        foreach($form["field"] as $k => $field) {
            if($field["name"] == "advert_category") {
                $field["is_required"] = true;
                if( ! isset($field["validator"]) || !is_array($field["validator"])) {
                    $field["validator"] = array();
                }
                $field["validator"][] = array( "name" => "is_required" );
    
                $form["field"][$k] = $field;
                break;
            }
        }
    
        return $form;
    }
    Thread Starter Perkik03

    (@perkik03)

    Is there a reason this function no longer works?

    Thread Starter Perkik03

    (@perkik03)

    Nevermind, I see you added the option to the widget.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Requiring Catagories’ is closed to new replies.