È possibile scrivere una query per ottenere quell'attività. C'è anche un filtro è possibile collegare in cui andranno chiamato dopo l'avatar è caricato (spiegato più avanti):
<?php
global $wpdb;
$query = "SELECT * FROM {$wpdb->prefix}bp_activity WHERE " .
"`type` = 'new_avatar' AND `user_id` = %d " .
"ORDER BY `date_recorded` DESC LIMIT 1";
$result =
$wpdb->get_row(
$wpdb->prepare($query, $user_id)
);
if ($result) {
// found an activity item for avatar upload
var_dump($result);
} else {
// user has not uploaded an avatar
}
risultato è simile:
stdClass Object
(
[id] => 2 <-- this is the activity ID
[user_id] => 1
[component] => profile
[type] => new_avatar
[action] => admin changed their profile picture
[content] =>
[primary_link] => http://example.com/wordpress/members/admin/
[item_id] => 0
[secondary_item_id] => 0
[date_recorded] => 2016-03-29 04:41:53
[hide_sitewide] => 0
[mptt_left] => 0
[mptt_right] => 0
[is_spam] => 0
)
c'è un'azione che si chiama, che si può collegarsi a quello che verrà chiamato quando questa attività avrà luogo. È xprofile_avatar_uploaded
e passa due parametri, $item_id
(ID utente) e $type
(ad esempio, ritaglio o telecamera). Questo filtro viene eseguito dopo il caricamento di un avatar.
Da qualche parte nelle funzioni, aggiungere:
add_action('xprofile_avatar_uploaded', 'callback');
function callback($user_id, $type)
{
// $user_id uploaded new avatar
}
ho trovato è possibile anche chiamare:
$img = bp_get_activity_avatar(['user_id' => $user_id]);
per ottenere il codice HTML per visualizzare l'avatar. Sono memorizzati in wp-content/uploads/avatars
.
Si può anche chiamare:
$url = bp_core_fetch_avatar(['item_id' => $user_id, 'html' => false]);
per ottenere solo l'URL completo del avatar.
hanno risolto giusto? – GeorgeWL