Advertisement
geminilabs

[site-reviews] Convert author name to author link

Oct 18th, 2021
1,213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. /**
  2.  * Convert the author name 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\ReviewAuthorTag $tag
  6.  * @return string
  7.  */
  8. add_filter('site-reviews/review/value/author', 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);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement