• Resolved chromaside

    (@chromaside)


    Hello!

    Love the plugin and it’s working great so far.

    I’m using it as a classifieds section for a local newspaper. However, only admins post ads, not users. Some ads that come in don’t have an email address attached, so I want to make email NOT a required field.

    I’ve seen a snippet that removes email entirely, but I just want to make it not a required field instead of removing it entirely.

    Can you help?

    Thanks!

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

    (@gwin)

    Hi,
    i am glad you are liking the plugin so far, to answer your question, you can make the email field optional either using the Custom Fields extension or by adding the code below in your theme functions.php file

    
    add_filter( "adverts_form_load", function( $form ) {
      if( $form['name'] != "advert" ) {
        return $form;
      }
      foreach( $form["field"] as $key => $field ) {
        if( $field["name"] == "adverts_email" ) {
          $form["field"][$key]["is_required"] = 0;
          unset( $form["field"][$key]["validator"][0] );
        }
      }
      return $form;
    } );
    
    Thread Starter chromaside

    (@chromaside)

    That totally worked! Thanks so much.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Make email not required’ is closed to new replies.