SubmitContent Created By and alias

jbudd 16 Jan, 2009
I am trying to use the the Submit Content form.

Please can you advise me how to populate the created_by field in jos_content with the current userid?
Currently it stores 0 (administrator?) so the author cannot subsequently edit his page.
Max_admin 18 Jan, 2009
Hi jbudd,

please show me the code in the "onSubmit after email" box of the form!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
jbudd 19 Jan, 2009
This is what I have in On Submit After Email:

<p><span style="color: #0000ff;"><strong>Thank you for submitting your story. You can view it by selecting "Practice Pages"</strong></span></p>
<?php
$_POST['catid'] = '30';
$_POST['id'] = '';
$_POST['sectionid'] = '6';
$_POST['state'] = '1';
$_POST['created'] = date("Y-m-d H:i:s");
?>


I can see it is easy to insert a static value here such as $_Post['state'] = '1' - to make the content item automatically published, but I dont know how to access the current user ID.

For the alias, in the standard submit content component there is some code which changes the title to lowercase and substitutes hyphens for spaces. My PHP is probably up to reproducing this function... I havent yet worked out the complete significance of article aliases in J1.5.


jb
GreyHead 19 Jan, 2009
Hi jbudd,

It's something like
<?php
$user = JFactory::getUser();
$_POST['id'] = $user->id;
?>

Bob
jbudd 19 Jan, 2009
Thanks Greyhead!

That suggestion works fine, except the field is 'created_by' not 'id'

jb
mkabwilliams 18 Mar, 2009
I'm also trying to do this. So would I change the onsubmit after email to.

<p><span style="color: #0000ff;"><strong>Thank you for submitting your story. You can view it by selecting "Practice Pages"</strong></span></p>
<?php
$_POST['catid'] = '30';
$_POST['created_by'] = $user->id;
$_POST['sectionid'] = '6';
$_POST['state'] = '1';
$_POST['created'] = date("Y-m-d H:i:s");
?>
GreyHead 18 Mar, 2009
Hi mkabwilliams,

That's how I understand it.

Bob
Max_admin 18 Mar, 2009
and before using
$user->id
you need:
$user = JFactory::getUser();


Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.