Support » Plugin: Multifile Upload Field for Contact Form 7 » [fixed] attachment requirement not enforced

  • This is a really simple fix, just follow the steps below:
    1. Goto your plugins folder and open multifile-for-contact-form-7.php in Notepad++
    2. Delete lines 106-107 and paste the following at line 106:

      if ($tag->is_required() ) {
          $result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
          }
    	  return $result;
      }

    3. Save, then FTP your edited php file to your server.

    I also added a new validation error message, because I didn’t like using the generic field one for files. If you want to add that, do the following:
    1. In Notepad++ at line 107, change invalid_required to file_required
    2. Goto line 264, hit return, and paste the following at the now-blank line 264:

    'file_required' => array(
    			'description' => __( "User has attached no files", 'contact-form-7' ),
    			'default' => __( "You must attach at least one file.", 'contact-form-7' )
    		),
    

    To clarify, the above will NOT change the stock CF7 upload error message for individual buttons. To do that, you’ll need to alter the CF7 plugin. This new message box only appears in the admin panel when you install (or edit) this multifile plugin.

    3. Save, then FTP your edited php file to your server. You’ll see the new message in the Contact Form admin panel where you can customize it.

    Enjoy!

    • This topic was modified 2 years, 12 months ago by IT Hertz.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Not Working

    if ($tag->is_required() ) {
    $result->invalidate( $tag, wpcf7_get_message( ‘file_required’ ) );
    }
    return $result;
    }

    ‘file_required’ => array(
    ‘description’ => __( “User has attached no files”, ‘contact-form-7’ ),
    ‘default’ => __( “You must attach at least one file.”, ‘contact-form-7’ )
    ),

    That should be delete lines 106-108. If you copy and paste exactly as I posted after that, it should work.

    Oh, also important: hit return on line 264 at the beginning of the line, not at the end.
    If you get confused as to editing out your prior edits, download a fresh copy of the php file and do the mods.

    • This reply was modified 2 years, 4 months ago by IT Hertz.
    • This reply was modified 2 years, 4 months ago by IT Hertz.
    • This reply was modified 2 years, 4 months ago by IT Hertz.

    I think I see what’s wrong, a superfluous curly bracket. Don’t know how that got in there. After you delete lines 106-108, paste this:

       if ($tag->is_required() ) {
          $result->invalidate( $tag, wpcf7_get_message( 'file_required' ) );
          return $result;
      }

    Then, hit return on the beginning of line 263 and paste the second block of code.

    I’m positive this worked for me before, or else I wouldn’t have bothered pasting it. But now it isn’t working. I’ll try to get it fixed.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[fixed] attachment requirement not enforced’ is closed to new replies.