BP_Attachment::set_upload_error_strings( array $param = array() )

Set Upload error messages.

Description

Used into the $overrides argument of BP_Attachment->upload()

Parameters

$param

(Optional) A list of error messages to add to BuddyPress core ones.

Default value: array()

Return

(array) $upload_errors The list of upload errors.

Source

File: bp-core/classes/class-bp-attachment.php

	public function set_upload_error_strings( $param = array() ) {
		/**
		 * Index of the array is the error code
		 * Custom errors will start at 9 code
		 */
		$upload_errors = array(
			0 => __( 'The file was uploaded successfully', 'buddyboss' ),
			1 => __( 'The uploaded file exceeds the maximum allowed file size for this site', 'buddyboss' ),
			2 => sprintf( __( 'The uploaded file exceeds the maximum allowed file size of: %s', 'buddyboss' ), size_format( $this->original_max_filesize ) ),
			3 => __( 'The uploaded file was only partially uploaded.', 'buddyboss' ),
			4 => __( 'No file was uploaded.', 'buddyboss' ),
			5 => '',
			6 => __( 'Missing a temporary folder.', 'buddyboss' ),
			7 => __( 'Failed to write file to disk.', 'buddyboss' ),
			8 => __( 'File upload stopped by extension.', 'buddyboss' ),
		);

		if ( ! array_intersect_key( $upload_errors, (array) $param ) ) {
			foreach ( $param as $key_error => $error_message ) {
				$upload_errors[ $key_error ] = $error_message;
			}
		}

		return $upload_errors;
	}

Changelog

Changelog
Version Description
BuddyPress 2.3.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.