Show block only when author is X
Last modified: April 7, 2007 - 13:04
I used this for my blog section and I also used the script that makes the block visible for a certain type of node. This way the block only shows on pages that are blog pages and that have been made by a certain user.
<?php
$match = FALSE;
$type = 'blog';
if (arg(0) == $type){
$match = TRUE;
}
else if (arg(0) == 'node' && is_numeric(arg(1))) {
$nid = arg(1);
$node = node_load(array('nid' => $nid));
$nodetype = $node->type;
$name = $node->name;
if ($type == $nodetype && $name == 'UsernameHere') {
$match = TRUE;
}
}
return $match;
?>
Slight Modification to Original Code for 5.2
I tried the above code and it was displaying all blocks on the main blog page. (/blog/)
To fix:
Comment out
$type = 'blog';and/*$type == $nodetype && */