bp_document_rename_folder( int $folder_id, string $title = '', string $privacy = '' )

This function will rename the folder name.

Description

Parameters

$folder_id

(Required)

$title

(Optional)

Default value: ''

$privacy

(Optional)

Default value: ''

Return

(bool|int)

Source

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

function bp_document_rename_folder( $folder_id = 0, $title = '', $privacy = '' ) {

	global $wpdb, $bp;

	if ( 0 === $folder_id && '' === $title ) {
		return false;
	}

	if ( (int) $folder_id > 0 ) {
		$has_access = bp_folder_user_can_edit( $folder_id );
		if ( ! $has_access ) {
			return false;
		}
	}

	if ( strpbrk( $title, "\\/?%*:|\"<>" ) !== false ) {
		return false;
	}

	$title = wp_strip_all_tags( $title );

	$q = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->document->table_name_folder} SET title = %s, date_modified = %s WHERE id = %d", $title, bp_core_current_time(), $folder_id ) ); // db call ok; no-cache ok;

	bp_document_update_privacy( $folder_id, $privacy, 'folder' );

	if ( false === $q ) {
		return false;
	}

	return $folder_id;
}

Changelog

Changelog
Version Description
BuddyBoss 1.4.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.