Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Change Default Avatar for User


James
Participant

@janismo

what I want is to have set of default avatars, with random one for every user.

idea was to have additional function:

`function randnum() {
// Range creates an array from a range (in this case 1 – 10)
$b = range(1,10);
// So the array looks like – array(1,2,3,4,5,6,7,8,9,10)
shuffle($b);
$r = array_values($b);
echo $r[rand(1,10)];
}`

this function will generate random number from 1-10 and path in code from link would look like:

`return get_stylesheet_directory_uri() .’/_inc/images/image-‘ . randnum() . ‘.png’;`

Result is that first function generates number (works), but in every part of BP (widget, content etc.) number for particular user is different + number from . randnum() . is not taken as part of path, but is displayed in frontend as link.

Skip to toolbar