Advertisement
daymobrew

Show custom text after author name

May 20th, 2015
640
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: AW Author Box
  4. Plugin URI: http://www.damiencarbery.com
  5. Description: For Riyad Arefin in Advanced WordPress Facebook group.
  6. Author: Damien Carbery
  7. Version: 0.1
  8.  
  9. $Id:  $
  10. */
  11.  
  12. add_filter('the_content', 'aw_author_box', 30);
  13. function aw_author_box($content) {
  14.     $user_id = get_the_author_meta('ID');
  15.  
  16.     // Start with the lowest capability.
  17.     if (user_can($user_id, 'read')) $user_string = 'Subscriber';
  18.     if (user_can($user_id, 'edit_posts')) $user_string = 'Contributor';
  19.     if (user_can($user_id, 'edit_published_posts')) $user_string = 'Author';
  20.     if (user_can($user_id, 'moderate_comments')) $user_string = 'Editor';
  21.     if (user_can($user_id, 'activate_plugins')) $user_string = 'Administrator';
  22.    
  23.     $author_box = sprintf('Author: <a href="%s">%s</a> (%s)', get_author_posts_url($user_id), get_the_author_meta('display_name'), $user_string );
  24.     return $content . $author_box;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement