What would I need to do to the submit content form to have it set the Author to a logged in users name?
Forums
set Author not Author Alias?
Hi mkabwilliams,
You'll ned to remove the 'name' input field, replace it with a hidden field add something like this to the OnSubmit Before code.
Bob
I'm not sure if you want the User's registered 'name' or 'username'; if you want the name then use $user->name
You'll ned to remove the 'name' input field, replace it with a hidden field add something like this to the OnSubmit Before code.
<?php
$user =& JFactory::getUser();
JRequest::setVar('name', $user->username, 'post');
?>
Bob
I'm not sure if you want the User's registered 'name' or 'username'; if you want the name then use $user->name
Can you elaborate,step by step?
I tried implementing what you said.
Within Form HTML
1. I removed the entire code:
2. I inserted:
In On Submit code - before sending email:
(PHP code with tags)
3. I inserted:
but no Joy. What am I doing Wrong.
What I am trying to attempt is when the user acesses the article, I want the current user name to be attached to the Article so it shows up under the user Profile under the Community Builder Profile Tab "Articles." The problem I am having is that I have to manually go into "Article Manager" and assign a registered Author to the Article. I would like the code to do it automatically while the user is logged in and using my form.
I tried implementing what you said.
Within Form HTML
1. I removed the entire code:
<div class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Your name:</label><input class="cf_inputbox required validate-alpha" maxlength="15" size="30" id="text_7" name="created_by_alias" type="text"><a onclick="return false;" class="tooltiplink"><img src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" width="16" border="0" height="16"></a><div class="tooltipdiv">Your name: :: Your nickname as you like it to appear with the story!</div></div><div class="clear"> </div></div>
2. I inserted:
<input type="hidden" name="name"/>
In On Submit code - before sending email:
(PHP code with tags)
3. I inserted:
<?php
$user =& JFactory::getUser();
JRequest::setVar('name', $user->username, 'post');
?>
but no Joy. What am I doing Wrong.
What I am trying to attempt is when the user acesses the article, I want the current user name to be attached to the Article so it shows up under the user Profile under the Community Builder Profile Tab "Articles." The problem I am having is that I have to manually go into "Article Manager" and assign a registered Author to the Article. I would like the code to do it automatically while the user is logged in and using my form.
Hi livineazy24,
I don't know what CB requires but for Joomla the column names in jos_content are 'created_by' which takes a User ID, not a name; and 'created_by_alias' which I think takes a text string. There is no 'name' column.
Bob
I don't know what CB requires but for Joomla the column names in jos_content are 'created_by' which takes a User ID, not a name; and 'created_by_alias' which I think takes a text string. There is no 'name' column.
Bob
Just to let the next guy know who is interested on how to complete this task (assigning the Author to the Article so it shows up when you have "Community Builder" Installed under the "Article" tab in the user profile.
Simply delete the code:
And insert this still within the HTML code:
Before the "Submit" code ie.
After the "Submit" Code (still under HTML):
Recap: here is the LOT! (What the code does: Submits the article to category id:34 and Section id:5 and publishes it right away.
Within the "Form HTML" code:
Within the "On Submit code - after sending e-mail"
Simply delete the code:
And insert this still within the HTML code:
Before the "Submit" code ie.
<div class="form_item"><div class="form_element cf_button"><input value="Submit Story" name="undefined" type="submit"></div><div class="clear"> </div></div>
<?php
$user =& JFactory::getUser();
$id = $user->get('id');
?>
After the "Submit" Code (still under HTML):
<input type="hidden" name="created_by" value="<?php echo $id ?>" />
Recap: here is the LOT! (What the code does: Submits the article to category id:34 and Section id:5 and publishes it right away.
Within the "Form HTML" code:
<div class="form_item"><div class="form_element cf_heading"><h1 id="" class="cf_text">Submit Your Poem!</h1></div><div class="clear"> </div></div>
<p>Note: It would be best to edit your text with a text editor before submitting.</p>
<div class="form_item"><div class="clear"> </div></div>
<div class="form_item"><p>Thank you for submitting your poetry!</p></div>
<div class="form_item"><div class="form_element cf_textbox"><label class="cf_label">Title:</label><input class="cf_inputbox required" maxlength="150" size="30" id="text_5" name="title" type="text">
<a onclick="return false;" class="tooltiplink"><img src="components/com_chronocontact/css/images/tooltip.png" class="tooltipimg" width="16" border="0" height="16" alt="Please give your poem a title">
</a>
</div>
<div class="clear"> </div></div>
<div class="form_item"><div class="form_element cf_textarea" style="width:600px;">
<label class="cf_label">Story body:</label>
<?php
$editor =& JFactory::getEditor();
echo $editor->display( 'fulltext', '' , '500', '400', '60', '20', false );
?>
</div><div class="clear"> </div></div>
<div class="form_item"><div class="clear"> </div></div>
<div class="form_item"><div class="form_element cf_captcha"><label class="cf_label">Enter code as shown</label><span>{imageverification}</span></div><div class="clear"> </div></div>
<?php
$user =& JFactory::getUser();
$id = $user->get('id');
?>
<div class="form_item"><div class="form_element cf_button"><input value="Submit Story" name="undefined" type="submit"></div><div class="clear"> </div></div>
<input type="hidden" name="created_by" value="<?php echo $id ?>" />
<input type="hidden" name="state" value="1"/>
<input type="hidden" name="sectionid" value="5"/>
<input type="hidden" name="catid" value="34"/>
Within the "On Submit code - after sending e-mail"
<p><span style="color: #000;"><?php echo $yourname?> thank you for submitting your poem and contributing to <bold>unboundpoetry.com </bold></span></p>
<p><span style="color: #000;">If you would like to submit another poem please click here: </span></p>
<input type="button" value="Submit Another Poem" onclick="document.location = 'index.php?option=com_chronocontact&chronoformname=userpoetrysubmit';">
<?php
$_POST['catid'] = '34';
$_POST['id'] = '';
$_POST['sectionid'] = '5';
$_POST['state'] = '1';
$_POST['created'] = date("Y-m-d H:i:s");
?>
This topic is locked and no more replies can be posted.