• We do have a problem with users adding advers without selecting a category. As we are showing all categories in an overview there is currently no way to findt adverts without any category.

    So we would like to set category as a required field when adding a new advert. Looked through support forum but could not find any related answer.

    If this is not working, how could we manage to add a “show all adverts without any category” element?

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

    (@gwin)

    Hi,
    you can make the Category field required either using the Custom Fields extension or by adding the code below in your theme functions.php file (or even better by creating a new blank WP plugin and adding the code there).

    
    add_filter( "adverts_form_load", function( $form ) {
        if( $form["name"] != "advert" ) {
            return $form;	
        }
        foreach( $form["field"] as $k => $f ) {
            if( $f["name"] == "advert_category" ) {
                $form["field"][$k]["validator"][] = array( "name" => "is_required" );
            }
        }
        return $form;
    } );
    
Viewing 1 replies (of 1 total)
  • The topic ‘Make Category required field’ is closed to new replies.