bp_members_avatar_upload_dir( string $directory = 'avatars', int $user_id )

Setup the avatar upload directory for a user.


Parameters Parameters

$directory

(string) (Optional) The root directory name. Optional.

Default value: 'avatars'

$user_id

(int) (Required) The user ID. Optional.


Top ↑

Return Return

(array) Array containing the path, URL, and other helpful settings.


Source Source

File: bp-members/bp-members-functions.php

function bp_members_avatar_upload_dir( $directory = 'avatars', $user_id = 0 ) {

	// Use displayed user if no user ID was passed.
	if ( empty( $user_id ) ) {
		$user_id = bp_displayed_user_id();
	}

	// Failsafe against accidentally nooped $directory parameter.
	if ( empty( $directory ) ) {
		$directory = 'avatars';
	}

	$path      = bp_core_avatar_upload_path() . '/' . $directory. '/' . $user_id;
	$newbdir   = $path;
	$newurl    = bp_core_avatar_url() . '/' . $directory. '/' . $user_id;
	$newburl   = $newurl;
	$newsubdir = '/' . $directory. '/' . $user_id;

	/**
	 * Filters the avatar upload directory for a user.
	 *
	 * @since 6.0.0
	 *
	 * @param array $value Array containing the path, URL, and other helpful settings.
	 */
	return apply_filters( 'bp_members_avatar_upload_dir', array(
		'path'    => $path,
		'url'     => $newurl,
		'subdir'  => $newsubdir,
		'basedir' => $newbdir,
		'baseurl' => $newburl,
		'error'   => false
	) );
}


Top ↑

Changelog Changelog

Changelog
Version Description
6.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.