[support] Default PHP Code for CCK field

Chris McCreery chris.mccreery at gmail.com
Fri Nov 2 04:09:20 UTC 2007


Thanks for the replay. I have created a CCK field for User Reference. Right
now it displays all possible users to select. I am trying to set the default
selected user to the current user. I go to the content type I created and
then select the field to configure. I have the option for a default value,
it lets me select a specific user or I can enter php code to make this
dynamic. So I would like to set the default selected item to be the current
user. All the suggestions I've tried in previous replies all result in the
following error when I submit the change to the custom field


The default value php code returned an incorrect value
Expected format :

array(
  0 => array('uid' => value for uid),
  // You'll usually want to stop here. Provide more values
  // if you want your 'default value' to be multi-valued :
  1 => array('uid' => value for uid),
  2 => ...
);

Returned value :

Any help would be awesome because as you can see I have limited coding
skills.

Thank you so much.

On 11/1/07, Cog Rusty <cog.rusty at gmail.com> wrote:
>
> On 11/2/07, Chris McCreery <chris.mccreery at gmail.com> wrote:
> > Ok I'm so lost here, does anyone know what I should be putting in here.
> >
> > So far I have
> >
> > global $user;
> > array ( 0 => array ('uid' => $user=>uid));
> >
> > Do I need return array? No idea what the format should be.
>
>
> Global $user is an object, not an array, so the user id is $user->uid
>
> Besides that, I can't say whether you need to return or to print
> something. I am not sure what you are trying to do, what errors
> exactly you are getting, or what doesn't work as it should.
>
>
> > On 11/1/07, Xavier Bestel <xavier.bestel at free.fr> wrote:
> > >
> > > Le jeudi 01 novembre 2007 à 16:28 -0400, Chris McCreery a écrit :
> > > > Grrrrrrrrrrrrrrrrrrrrrrrrrrr, ok nothing seems to work everything I
> > > > put in there gives me the same error.
> > > >
> > > > This is what I have now.
> > > >
> > > > global $user;
> > > > return array(0 => array('uid' => $user=>uid));
> > >
> > > Maybe try
> > > array('uid' => $user['uid'])
> > >
> > >
> > > --
> > > [ Drupal support list | http://lists.drupal.org/ ]
> > >
> >
> >
> >
> > --
> > Chris McCreery
> > --
> > [ Drupal support list | http://lists.drupal.org/ ]
> >
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>



-- 
Chris McCreery
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20071102/21ccf225/attachment-0001.htm 


More information about the support mailing list