The view module has a great function when set a menu tab with contextual filter user:uid, so the user that is author of that node will be able to see the content. Lets say for an example the flag module has a view bookmarks, so when a user choose some node to follow/flag it will be available in his user/%/bookmarks.
How can I do this with custom code? I have my code here as a test:
<?php
function mymodule_menu() {
$items = array();
$items['user/%/add-news'] = array(
'title' => 'Hello World',
'page callback' => 'mymodule_user_news',
'page arguments' => array(1),
'access arguments' => array('access content'),
);
return $items;
}
function mymodule_user_news() {
return 'Hello world';
}
This "Hello World" everybody can see it. Of course, because I'm using
'access arguments' => array('access content'),
How can I set this page to be visible only for user author?
I'm planning to add here a form, so the user can fill the form and send it to the administrator of the website.
Oh, by the way when I set a link only visible to the author user I use this echo l(t("Profile edit"), 'user/' . $GLOBALS['user']->uid . '/edit');
How can I use the $GLOBALS['user']->uid in a module?