By ljenkin2 on
As the site administrator, when I create content for the main page I do not want my user name and the date I created that content to appear. I tried removing the code from the node.php file, but it takes an all or nothing approach (either everyone has that information posted, or no one does). I also tried to alter the theme code to read:
<?php if ($display_submitted): ?>
<?php if ($name != "myusername"): ?>
<span class="submitted"><?php print $date; ?> - <?php print $name; ?></span>
<?php endif; ?>
<?php endif; ?>
hoping that if it identified my user name as being equal to the $name variable it would not print anything under it. This did not work because for some reason it always registers $name as not being equal to my user name and prints my name and the date anyway. I want it to print the date and user name for all other users. Any ideas out there?
Comments
I would add this to my themes
I would add this to my themes template.php file (or create a module)
Changing YOURTHEMENAME to your themes actual name and YOUR_USER_ID to the numeric user id for your account.
(You if probably fails because $name is themed and is not simply your user name).
Why not create a new
Why not create a new content-type (story-admin), and set your theme to not display the submitted by line for that content type. Only you would use that type. And whenever you want the line to appear, just use the standard story type.
No code necessary.
Replace $name with $user->name
In your code use $user->name instead of $name. $name does not contain user name. Object $user contains the user name.
Hi, You can try any of the
Hi,
You can try any of the below codes :
First method :
You active theme's Node.tpl.php
Second Method :
In you are active theme's template .php :
Hope this helps.
Regards
Sagar
Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form
Hello All, I've been
Hello All,
I've been searching for some time and am unable to find a way to hide the submitted by information based on user roles.
I would only like to show the submitted by information to authenticated users. Can someone please help me modify the above code?
Many thanks in advance!
Using the second method above
Using the second method above you can use
Remember to replace YOURTHEMENAME with your actual themes name. If using an existing theme it may already have the function in which case you would add the code in the example to the existing function.
[EDIT: fix call to user_logged_in()]
Thanks for your help nevets,
Thanks for your help nevets, unfortunatley I am receiving the following error:
I have created a new template file in my sub theme (fusion starter) and am using the following:
Also, would it be possible to provide a snippet that lets me select which roles that the post information should be visible to?
Many thanks for you help!
Fixed my earlier post (the
Fixed my earlier post (the 'call' should not be there). As for "lets me select which roles that the post information should be visible to" the original snippet with one small change (a '!' before in_array()) will work
Thanks so much nevets! That
Thanks so much nevets! That worked perfectly.
I had to make one minor change, using the Fusion theme. I had to replace 'display_submitted' with 'submitted' in order for it to work.