Since you are using the %uid wildcard in the menu definition, your kidb_profile_redirect_user()
is not getting a user ID, but what uid_load()
would be returning. That function is not defined from any module and that is the reason why you get the "page not found" error.
The list of wildcards defined from Drupal 6 is reported in Wildcard usage and core's wildcards. A description of what auto-loader wildcards are is given in hook_menu()
:
Wildcards in Paths
Simple Wildcards
Wildcards within paths also work with integer substitution. For example, your module could register path 'my-module/%/edit':
$items['my-module/%/edit'] = array(
'page callback' => 'mymodule_abc_edit',
'page arguments' => array(1),
);
When path 'my-module/foo/edit' is requested, integer 1 will be replaced with 'foo' and passed to the callback function. Note that wildcards may not be used as the first component.
Auto-Loader Wildcards
Registered paths may also contain special "auto-loader" wildcard components in the form of '%mymodule_abc', where the '%' part means that this path component is a wildcard, and the 'mymodule_abc' part defines the prefix for a load function, which here would be named mymodule_abc_load()
. When a matching path is requested, your load function will receive as its first argument the path component in the position of the wildcard; load functions may also be passed additional arguments (see "load arguments" in the return value section below). For example, your module could register path 'my-module/%mymodule_abc/edit':
$items['my-module/%mymodule_abc/edit'] = array(
'page callback' => 'mymodule_abc_edit',
'page arguments' => array(1),
);
When path 'my-module/123/edit' is requested, your load function mymodule_abc_load()
will be invoked with the argument '123', and should load and return an "abc" object with internal id 123:
function mymodule_abc_load($abc_id) {
return db_query("SELECT * FROM {mymodule_abc} WHERE abc_id = :abc_id", array(':abc_id' => $abc_id))->fetchObject();
}
You probably meant to use %user, which would return to your page callback the object returned from user_load()
. Using that wildcard avoids you check in your code that the user ID is valid (e.g. there is a user account with that ID), but also means that you should change your code to match the following.
function kidb_profile_redirect_user($account) {
drupal_goto('profile-main_profile/' . $account->uid . '/edit');
}