@djoni7811
This snippet should do the trick (add it to your functions.php).
Keep in mind that your WP_Comment object most have comment_author
field set. This is the default wp field for comments author, some plugins use a different field, if so, just make sure you use the correct one.
Let me know if it work for you.
function background_from_nickname( $url_args, $id_or_email ) {
$user = false;
if ( $id_or_email instanceof WP_Comment ) {
if ( ! empty( $id_or_email->user_id ) ) {
$user = get_user_by( 'id', (int) $id_or_email->user_id );
}
if ( ( ! $user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author ) ) {
$hash = $id_or_email->comment_author . '@localhost.com';//add @localhost.com is optional
$hash = md5( strtolower( trim( $hash ) ) );
$url_args['background'] = substr( $hash, 0, 6 );
}
}
return $url_args;
}
add_filter( 'leira_letter_avatar_url_args', 'background_from_nickname', 10, 2 );