b2evolution b2evolution

  • Sign in
  • Sign up
  • About
  • Downloads
  • Hosting
  • Docs
  • Support
  • Sign in
  • Sign up
  • Manuals Home
  • Latest Updates
 
  1. b2evolution CMS User Manual
  2. Developer Reference
  3. How to... (Customize)
  4. How to Show the Assigned Author of a post

How to Show the Assigned Author of a post

Posts are by default assigned to the creator - the author who is logged in when they are created. Sometimes you may wish to change this either at editing time or subsequently. This hack can be used to change the displayed author of a post by just changing the assigned author in the post editing form.

Show the assigned author of the article and other details

If no author is assigned, display the creator of the article.

Show the Prefered Name (Identity Shown) with a link to all the articles of that person


<?php  
  $Item->get_creator_User(); 
  if( $Item->assigned_user_ID ) 
    { 
    $the_author = $UserCache->get_by_ID( $Item->assigned_user_ID ); 
    } 
    else 
    { 
    $the_author = $Item->Author; 
    } 
    echo '<a href="'.url_add_param( $Blog->get( 'blogurl', 'htmlattr' ), 'author='.$the_author->ID).'" title="Browse all articles from '.$the_author->get_preferred_name().'"><img src="rsc/icon_16_author.gif" border="0"></a>'; 
?>

And once you did that, you want the messageform-link to go to the right user, right ?

$the_author->msgform_link( $Blog->get('msgformurl'),' ',' ','#','Send an e-mail to '.$the_author->get_preferred_name(),'' );

Show simply the assigned author name

If you just want to show the assigned author name (not any lists of links or message form) this code will do it:

<?php   
  $Item->get_creator_User();  
  if( $Item->assigned_user_ID )  
    {  
    $the_author = $UserCache->get_by_ID( $Item->assigned_user_ID );  
    }  
    else  
    {  
    $the_author = $Item->Author;  
    }  
    echo $the_author->get_preferred_name();  
?>

You should insert this code into your active _main.php file (the one in whichever template you are using) in the section called ‘—START OF POSTS—’. It should ‘’replace'’ the lines that read something like:

$Item->author( '<strong>', '</strong>' );
$Item->msgform_link( $Blog->get('msgformurl') );
  • You will need to remove the surrounding <?php … ?> tags if you are inserting it into an existing php statement.
Created by fatimahnasra • Last edit by fplanque on 2020-06-09 00:24 • •

No feedback yet

On this page

  • Show the assigned author of the article and other details
  • Show simply the assigned author name

Search the Manual

Content Hierarchy

  • b2evolution CMS User Manual
  • User's Guide
  • Installation / Upgrade
  • Front-office Reference
  • Back-office Reference
  • Developer Reference
    • Website Skins/Themes
    • Email Skins/Themes
    • b2evolution Files
    • Website Integration
    • Plugins
    • Debugging
    • Technical Reference
    • Hacks
    • Credits
    • Development
    • How to... (Customize)
      • How to upgrade a b2evo blog template to an evoSkin
      • Popup Comments
      • FTP 101: How to upload and manage files on your web server
      • Working with the Open Graph Protocol
      • How to - Use "honeypots" in your forms
      • I made a change but my blog is not updated
      • Turn A Skin Into A Template
      • Where is the Templates Tab?
      • Display Recent Posts In The Sidebar
      • Recent Comments In The Sidebar
      • Include Item Feedback
      • How to display comments, trackbacks and pingbacks UNMIXED
      • Change the way my blog looks
      • How to use b2evolution as a CMS
      • How to Show the Assigned Author of a post
      • How to change the "Read More" link
      • How to call a blog through xyz.php instead of index.php?blog=x
      • How to turn a Skin into a Template
      • How To use Pop-Up Comments in your evoSkin
      • How to add a smilie to your toolbar
      • How to display the posts' author
      • Dev Menu
    • Scheduled Tasks Reference
  • Operations Reference
  • Advanced Topics
  • Glossary
  • Archives
Social CMS software

This online manual is powered by b2evolution CMS – A complete engine for your website.

About b2evolution

  • What is it?
  • Features
  • Getting Started
  • Screenshots
  • Online demo
  • Testimonials
  • Design philosophy
  • Free & open source
  • Terms of service

Downloads

  • Latest releases
  • Skins
  • Plugins
  • Language packs

About us

  • About us
  • Contact

Webhosting Guide

  • Web hosting blog
  • Best web hosting
  • Cheap web hosting
  • Green web hosting
  • Hosting with SSH
  • VPS hosting
  • Dedicated servers
  • Reseller hosting
  • Int'l: UK / France

Docs & Support

  • Online manual
  • Forums
  • Hire a pro !

Other

  • Adsense
  • Press room
  • Privacy policy

Stay in touch

  • GitHub
  • Twitter
  • Facebook
  • LinkedIn
  • News blog
  • RSS feed
  • Atom feed

Founded & Maintained by François Planque