Title: Check file name
Last modified: August 22, 2016

---

# Check file name

 *  Resolved [rampaaa](https://wordpress.org/support/users/rampaaa/)
 * (@rampaaa)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/check-file-name/)
 * Hi everybody,
    I want the users to insert a “magic” word in the file name. If
   they don’t do this, the file can’t be uploaded. What function I have to custom?
 * [https://wordpress.org/plugins/buddydrive/](https://wordpress.org/plugins/buddydrive/)

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

 *  Thread Starter [rampaaa](https://wordpress.org/support/users/rampaaa/)
 * (@rampaaa)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/check-file-name/#post-5794141)
 * I solved the problem by changing the function “buddydrive_save_new_buddyfile()”
   in buddydrive-item-ajax.php
 *  [Mathieu Viet](https://wordpress.org/support/users/imath/)
 * (@imath)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/check-file-name/#post-5794369)
 * You shouldn’t edit a plugin’s file. Next upgrade will remove your customization.
 * I’ll look at a way to allow you do this from a bp-custom.php file for example.
 *  [Mathieu Viet](https://wordpress.org/support/users/imath/)
 * (@imath)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/check-file-name/#post-5794384)
 * Hi this will be possible in next version (1.2.2)
 * You’ll then need to use this code :
 *     ```
       function rampaaa_custom_errors( $upload_error_messages = array() ) {
       	return array(
       		20 => __( 'Your file need to contain the word &quot;magic&quot;' ),
       	);
       }
       add_filter( 'buddydrive_get_upload_error_strings', 'rampaaa_custom_errors', 10, 1 );
   
       function rampaaa_check_filename( $file = array() ) {
       	if ( ! empty( $file['name'] ) && false === strpos( $file['name'], 'magic' ) ) {
       		$file['error'] = 20;
       	}
   
       	return $file;
       }
       add_filter( 'buddydrive_upload_errors', 'rampaaa_check_filename', 10, 1 );
       ```
   
 * I should release 1.2.2 in a couple of days.

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

The topic ‘Check file name’ is closed to new replies.

 * ![](https://ps.w.org/buddydrive/assets/icon-256x256.png?rev=3305954)
 * [BuddyDrive](https://wordpress.org/plugins/buddydrive/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/buddydrive/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/buddydrive/)
 * [Active Topics](https://wordpress.org/support/plugin/buddydrive/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/buddydrive/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/buddydrive/reviews/)

## Tags

 * [check](https://wordpress.org/support/topic-tag/check/)
 * [control](https://wordpress.org/support/topic-tag/control/)
 * [file](https://wordpress.org/support/topic-tag/file/)
 * [name](https://wordpress.org/support/topic-tag/name/)

 * 3 replies
 * 2 participants
 * Last reply from: [Mathieu Viet](https://wordpress.org/support/users/imath/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/check-file-name/#post-5794384)
 * Status: resolved