Hi all. I need to add some infos to $user variable. I have thinked that hook_user() is my "hook" :)
So I have write a function that add the infos to the $account:
function mw_livelloUtenti_user($op, &$edit, &$account, $category = NULL) { switch ($op) { case "login" : case "load" : if ($account->uid != NULL || $account->uid != 0) {
$tmp = db_query("SELECT mw.* FROM mw_lU AS mw LEFT JOIN mw_lU_user AS mwu ON mw.luid = mwu.luid WHERE mwu.uid = %d",$account->uid); $account->level = db_fetch_array($tmp); //print_r($account); //Ok, data are inserted (fields: level, data1, data2) } break; } }
Now, why when one of my other module try to access to $user->account this field is NULL ? Plz help me.
M.
Quoting Davide Michel 'ZioBudda' Morelli michel@ziobudda.net:
Hi all. I need to add some infos to $user variable. I have thinked that hook_user() is my "hook" :)
So I have write a function that add the infos to the $account:
function mw_livelloUtenti_user($op, &$edit, &$account, $category = NULL) { switch ($op) { case "login" : case "load" : if ($account->uid != NULL || $account->uid != 0) {
$tmp = db_query("SELECT mw.* FROM mw_lU AS mw LEFT JOINmw_lU_user AS mwu ON mw.luid = mwu.luid WHERE mwu.uid = %d",$account->uid); $account->level = db_fetch_array($tmp); //print_r($account); //Ok, data are inserted (fields: level, data1, data2) } break; } }
Now, why when one of my other module try to access to $user->account this field is NULL ? Plz help me.
The user information is stored in a global $user and is also stored in the session. If you don't save your additional data in the session then that is likely the reason your "other module" doesn't see the data; especially if the other module references the data with a new page view.
Earnie -- http://for-my-kids.com/ -- http://give-me-an-offer.com/
Hi,
i am playing around with Drupal 6.1. I set up some user accounts and checked the permissions for them to be able to create/edit and delete the page content.
While i can create the page with the option showing up under the Create Content menu link, i don't seem to be able to edit it afterwards. It does not show up anywhere (except under the admin->content link, which the normal user does not and should not have access to). I expected the edit link to show up under the my account settings for the user who created the page. But it does not.
What am i missing?
mat
While i can create the page with the option showing up under the Create Content menu link, i don't seem to be able to edit it afterwards. It does not show up anywhere (except under the admin->content link, which the normal user does not and should not have access to). I expected the edit link to show up under the my account settings for the user who created the page. But it does not.
Check Input Formats and the configuration there. Insure that the user roles in question have rights to the input format used for the page. That's how Drupal 5 works anyhow. :)
Fred
Also, you seem to be implying that because the user doesn't see it on their my accounts page, that they don't have privileges to edit it. This statement may not be true. If the user navigated to the page directly by its node/### url. They would normally see an edit tab.
Said another way. Drupal does not (without additional modules) by default provide a page that shows the user the content that they can edit.
The views module is one module that you can download that gives you the ability to create a page to show a user all the content that they have authored.
Clear as mud ;)?
Dave
-----Original Message----- From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Matt Funk Sent: Wednesday, March 05, 2008 9:40 AM To: support@drupal.org Subject: [support] A (probably) trivial question
Hi,
i am playing around with Drupal 6.1. I set up some user accounts and checked the permissions for them to be able to create/edit and delete the page content.
While i can create the page with the option showing up under the Create Content menu link, i don't seem to be able to edit it afterwards. It does not show up anywhere (except under the admin->content link, which the normal user does not and should not have access to). I expected the edit link to show up under the my account settings for the user who created the page. But it does not.
What am i missing?
mat
Thanks for the directions,
however, it seems that most modules do not yet have a 6.x version? So it is probably still better to use 5.x?
mat
On Wednesday 05 March 2008 11:23, Metzler, David wrote:
Also, you seem to be implying that because the user doesn't see it on their my accounts page, that they don't have privileges to edit it. This statement may not be true. If the user navigated to the page directly by its node/### url. They would normally see an edit tab.
Said another way. Drupal does not (without additional modules) by default provide a page that shows the user the content that they can edit.
The views module is one module that you can download that gives you the ability to create a page to show a user all the content that they have authored.
Clear as mud ;)?
Dave
-----Original Message----- From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Matt Funk Sent: Wednesday, March 05, 2008 9:40 AM To: support@drupal.org Subject: [support] A (probably) trivial question
Hi,
i am playing around with Drupal 6.1. I set up some user accounts and checked the permissions for them to be able to create/edit and delete the page content.
While i can create the page with the option showing up under the Create Content menu link, i don't seem to be able to edit it afterwards. It does not show up anywhere (except under the admin->content link, which the normal user does not and should not have access to). I expected the edit link to show up under the my account settings for the user who created the page. But it does not.
What am i missing?
mat
Yes, while the 6.x release is exciting, it's probably not going to work for many production sites until more modules are released and stabilized in 6.x. Even drupal.org stated they would keep using 5.x until required modules are updated.
.s
Matt Funk wrote:
Thanks for the directions,
however, it seems that most modules do not yet have a 6.x version? So it is probably still better to use 5.x?
mat
On Wednesday 05 March 2008 11:23, Metzler, David wrote:
Also, you seem to be implying that because the user doesn't see it on their my accounts page, that they don't have privileges to edit it. This statement may not be true. If the user navigated to the page directly by its node/### url. They would normally see an edit tab.
Said another way. Drupal does not (without additional modules) by default provide a page that shows the user the content that they can edit.
The views module is one module that you can download that gives you the ability to create a page to show a user all the content that they have authored.
Clear as mud ;)?
Dave
-----Original Message----- From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Matt Funk Sent: Wednesday, March 05, 2008 9:40 AM To: support@drupal.org Subject: [support] A (probably) trivial question
Hi,
i am playing around with Drupal 6.1. I set up some user accounts and checked the permissions for them to be able to create/edit and delete the page content.
While i can create the page with the option showing up under the Create Content menu link, i don't seem to be able to edit it afterwards. It does not show up anywhere (except under the admin->content link, which the normal user does not and should not have access to). I expected the edit link to show up under the my account settings for the user who created the page. But it does not.
What am i missing?
mat
You probably need to call user_load() -- please read through this issue and the issues that it references:
- Marc
Davide Michel 'ZioBudda' Morelli wrote:
Hi all. I need to add some infos to $user variable. I have thinked that hook_user() is my "hook" :)
So I have write a function that add the infos to the $account:
function mw_livelloUtenti_user($op, &$edit, &$account, $category = NULL) { switch ($op) { case "login" : case "load" : if ($account->uid != NULL || $account->uid != 0) {
$tmp = db_query("SELECT mw.* FROM mw_lU AS mw LEFT JOINmw_lU_user AS mwu ON mw.luid = mwu.luid WHERE mwu.uid = %d",$account->uid); $account->level = db_fetch_array($tmp); //print_r($account); //Ok, data are inserted (fields: level, data1, data2) } break; } }
Now, why when one of my other module try to access to $user->account this field is NULL ? Plz help me.
M.
Yes that's right. User_load is not called all the time, but only when a module decides it needs all the users profile information, etc.
So in the module that needs access to this, it should call user_load($user->uid) in order to make sure it gets all profile fields, and your hook_user code is executed.
If you truly need this data populated every page load, and are coding for 5.x, you can move your code into hook menu (!$may_cache section) in a module to modify the global $user object instead. Hook init could be used but you'll find not all the drupal api functions are available cause drupal hasn't fully bootsrapped yet (particularly when caching is enabled).
In 6.x hook_init is a more appropriate place to do "every page" loading of data into the global user object.
Dave
-----Original Message----- From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Marc Poris Sent: Wednesday, March 05, 2008 9:48 AM To: support@drupal.org Subject: Re: [support] Add some info to $user
You probably need to call user_load() -- please read through this issue and the issues that it references:
- Marc
Davide Michel 'ZioBudda' Morelli wrote:
Hi all. I need to add some infos to $user variable. I have thinked
that
hook_user() is my "hook" :)
So I have write a function that add the infos to the $account:
function mw_livelloUtenti_user($op, &$edit, &$account, $category =
NULL) {
switch ($op) { case "login" : case "load" : if ($account->uid != NULL || $account->uid != 0) { $tmp = db_query("SELECT mw.* FROM mw_lU AS mw LEFT
JOIN
mw_lU_user AS mwu ON mw.luid = mwu.luid WHERE mwu.uid =
%d",$account->uid);
$account->level = db_fetch_array($tmp); //print_r($account); //Ok, data are inserted (fields:level, data1, data2) } break; } }
Now, why when one of my other module try to access to $user->account this field is NULL ? Plz help me.
M.
On Wed, 05 Mar 2008 17:31:49 +0100 Davide Michel 'ZioBudda' Morelli michel@ziobudda.net wrote:
Now, why when one of my other module try to access to $user->account this field is NULL ?
I thought it was automatic too and that load hook was fired as soon as user login... but actually you've to call user_load.