I overrode bp_core_avatar_handle_upload
mit der folgenden Funktion. Er ruft bp_core_avatar_handle_upload in ihm auf, vermeidet jedoch eine Endlosschleife, indem er den Wert einer globalen Variablen einstellt und überprüft.
global $my_bp_group_avatar_upload;
function my_bp_group_avatar_upload($upload, $file, $upload_dir_filter)
{
// Global.
global $my_bp_group_avatar_upload;
// Check upload filter.
if ($upload_dir_filter != ‘groups_avatar_upload_dir’)
return;
// Check if this is the second call.
if ($my_bp_group_avatar_upload !== 2)
{
// We are being called for the first time!
// We are about to call the second time.
$my_bp_group_avatar_upload = 2;
// Call the function.
// We’re calling ourselves too, but this time the global equals 2, so we are now in the else statement.
if (bp_core_avatar_handle_upload($file, $upload_dir_filter)) {
// Do stuff here, the upload was a success.
}
// We’ve executed the function. We can bail out of the original function run.
return FALSE;
} else {
// We have been called a second time, so set this to something other than 2.
$my_bp_group_avatar_upload = 0;
// We want to continue with the execution.
return TRUE;
}
}
add_filter(‘bp_core_pre_avatar_handle_upload’, ‘my_bp_group_avatar_upload’, 10, 3);
Können Sie Details darüber teilen, wo Bild in Buddypress hochgeladen werden soll? – user5200704
das normale Bild hochladen http://DOMAIN.COM/members/USERNAME/media/photo/ – Peter
Medien/Foto ist nicht zur Verfügung stellen buddypress default Was ist externes Plugin von buddypress, wenn ja, geben Sie mir Plugin-Namen oder Link, die Plugin verwenden. – user5200704