This was exactly what I was looking to do in order to show a pupil's self-set target grade on the front page when they log on to remind them (Subjects that use books have stickers on the front - I wanted something a bit more hi-tech!)
The code I've put in my block is shown below:
<?php //$Id: block_target_level.php,v 1.0 2009/03/20 15:42:44 defacer Exp $
class block_target_level extends block_base {
function init() {
$this->title = 'My Target';
$this->version = 2009032000;
}
function get_content() {
global $USER;
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass;
$this->content->text = 'Target level:<br>'.$USER->NCLevel;
$this->content->footer = '';
return $this->content;
}
}
?>
The user field that I have created is called 'NCLevel' and I can see this when I look at a profile. However, it won't show up in the block on the front page. If I change the code to something like '$USER->description' it quite happily shows the description field.
Any ideas?! Many thanks in advance!
Steve