I have a Content type Board. All authenticated users can add boards. when i displaying the Board's Nodes i am also showing the author name. All going good. But when a user delete his account i set his status as blocked. If a user has been blocked then i want to show Anonymous author on board's node created by that blocked user. I searched here and there but could not find solution. Any Help please Thanks in Advance.
2 Answers
You may use
function theme_username($variables)
https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_username/7.x
$username = $variables['name'];
Check if user blocked
$variables['name'] = 'anonymous';
-
I could not solve by this. but it helped me a lot to fix my problem. thanks– IqbalCommented Oct 20, 2016 at 14:52
And finally, i solved it by following code:
<?php $author= user_load($uid); ?>
<?php if ($display_submitted): ?>
<span class="submitted">
<!-- For blocked user set the user name as Anonymous -->
<?php if(user_is_blocked($author->name)): ?>
<span> <a href="#" title="" class="username" ><?php print t('Anonymous'); ?></a></span>
<?php else: ?>
<?php print($user_picture); ?>
<?php print($submitted);?>
<?php endif;?>
</span>
<?php endif; ?>
thanks