[ckan-dev] Add user name and email to form

Alex (Maxious) Sadleir maxious at gmail.com
Tue Jan 20 03:40:12 UTC 2015


In your custom form template, you should have access to c.user (just
username) and c.userobj variables. eg.
https://github.com/datagovau/ckanext-agls/blob/master/ckanext/agls/templates/package/snippets/package_form.html#L37

If you turn on debug in your config ini file, you can browse what
variables are available in what template files eg.

c.user: u'maxious'
c.userobj: <User id=d279a17d-e917-4974-8b73-fea65c9068a1 name=maxious
openid=None password=xxxx5 fullname=Alex S email=m at m.com apikey=xxx
created=2014-08-01 12:11:39.987450 reset_key=None about=
activity_streams_email_notifications=False sysadmin=True state=active>

On Tue, Jan 20, 2015 at 2:10 AM, Funquist Tomas <tomas.funquist at smhi.se> wrote:
> Hi!
> I have to clarify my question. I know how to write a plugin and how to add extra fields. I have fields for contact information. What I want to do is to fill in the fields with the logged in users name and email so that he doesn't have to fill it in him self. How can I get hold of the users name and email so that I can fill it in at page load?
> /Tomas
>
> -----Ursprungligt meddelande-----
> Från: ckan-dev [mailto:ckan-dev-bounces at lists.okfn.org] För Joe Tsoi
> Skickat: den 19 januari 2015 15:40
> Till: CKAN Development Discussions
> Ämne: Re: [ckan-dev] Add user name and email to form
>
> You probably want to take look at the custom field tutorial here
> (http://docs.ckan.org/en/latest/extensions/adding-custom-fields.html)
>
> On 19 January 2015 at 13:09, Funquist Tomas <tomas.funquist at smhi.se> wrote:
>> Hello!
>>
>> I want to add the users name and email to fields in the dataset form
>> when creating a new dataset. Is that possible?
>>
>> /Tomas
>>
>>
>>
>>
>> _______________________________________________
>> ckan-dev mailing list
>> ckan-dev at lists.okfn.org
>> https://lists.okfn.org/mailman/listinfo/ckan-dev
>> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev



More information about the ckan-dev mailing list