geminilabs

[site-reviews] Convert avatar to author link

Nov 21st, 2018 (edited)
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. /**
  2.  * Convert the avatar to an author link (if the author is an existing user)
  3.  * Paste this in your active theme's functions.php file.
  4.  * @param string $value
  5.  * @param \GeminiLabs\SiteReviews\Modules\Html\Tags\ReviewAvatarTag $tag
  6.  * @return string
  7.  */
  8. add_filter('site-reviews/review/value/avatar', function ($value, $tag) {
  9.     if ($user = get_userdata($tag->review->author_id)) {
  10.         $authorUrl = get_author_posts_url($user->ID);
  11.         return sprintf('<a href="%s">%s</a>', $authorUrl, $value);
  12.     }
  13.     return $value;
  14. }, 10, 2);
Add Comment
Please, Sign In to add comment