How to show everyone´s profile except if it belongs to the admin?
Hi there!
I´m adding to my profiles the snippet that shows each user their last created nodes.
I´m using it to show each author´s articles, but as the admin of the site creates stuff that isn´t articles, but site´s internal pages, I don´t want people to access that snippet, or access her prfile at all.
(I´m talking of "articles" in a wider sense of the term, not of the "article" nodetype).
The snippet is:
Recent Posts
<?php
$uid = arg(1);
$nlimit = 5;
$result = db_query("SELECT n.created, n.title, n.nid, n.changed
FROM node n
WHERE n.uid = $uid
AND n.status = 1
ORDER BY n.changed
DESC LIMIT $nlimit");
$output3 .= "<div class=\"item-list\"><ul>\n";
$output3 .= node_title_list($result);
$output3 .= "</ul></div>";
print $output3;
?>Could I add to this snippet something like don´t show [this] if [this snippet belongs to user Nº 1]?
I don´t know about php (as you can see ;-), so I´m clueless about how to code this...
I´ve read at the forum how to hide certain stuff according to certain role´s permissions, but I want the contrary:
To show to everyone a snippet result, except when the information that the snippet shows belongs to user X
How can I make that possible?
Thanks!!
Rosamunda

An if check?
Like so?
<?php
$uid = arg(1);
if ($uid != 1) {
$nlimit = 5;
$result = db_query("SELECT n.created, n.title, n.nid, n.changed
FROM node n
WHERE n.uid = $uid
AND n.status = 1
ORDER BY n.changed
DESC LIMIT $nlimit");
$output3 .= "<div class=\"item-list\"><ul>\n";
$output3 .= node_title_list($result);
$output3 .= "</ul></div>";
print $output3;
}
?>
A more generic way is to use/check roles
For this to be more generic for usage on several sites where for example more than one administrator is active, the administrators should all share an admin role. Then the query test should not be on uid!=1, but on that particular admin role (may use the role name and not the number to avoid confusing people).
For that one must use NOT IN (Select ...) and join the node table with the users table and that one again with the roles table to get the role, though.
Btw - alternatively if it is sufficient to only avoid a certain type of content, for example "page", then a test on that could do the trick. One can also use the contributed ContentO module to create special new content types (clones of the "story" content type), and make sure all admin posts use that/those content types, and not the other ones. But sometimes it may be sufficient to limit the "page" content type to only admins.
Thanks for your help! but...
Wouldn´t that show the snippet if user 1?
Thanks again for your patience and help!
:-)
No
it is using the != operator so it will run the code for everyone NOT equal to uid 1.
Not equals is !=
Equals is ==
sorry for the silly question
sorry for the silly question (:embarrased:)
THANK YOU VERY MUCH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
I´ve tested it and IT WORKS LIKE A CHARM!!!!
THANKS!!!!!
Rosamunda