Keyword

Changing author on frontend edit form

  • Richard Belsey
  • Richard Belsey's Avatar Topic Author
  • Offline
  • New Member
More
8 years 2 weeks ago #157691 by Richard Belsey
Changing author on frontend edit form was created by Richard Belsey
When adding/editing an item in the backend the author can be selected but I do not have this ability in the frontend via the menu item type 'Edit item form'. I need to do this because the logged-in user will add items on behalf of other authors. Can it be enabled?

Please Log in or Create an account to join the conversation.

  • Fábio Jordan
  • Fábio Jordan's Avatar
  • Offline
  • Senior Member
  • Nothing like a good coffee to make a better web
More
8 years 2 weeks ago #157693 by Fábio Jordan
Replied by Fábio Jordan on topic Changing author on frontend edit form
Hi, Richard.

This is the code used (in backend) to change the author:
<span id="k2Author"><?php echo $this->row->author; ?></span>
<?php if($this->mainframe->isAdmin() || ($this->mainframe->isSite() && $this->permissions->get('editAll'))): ?>
<a class="modal k2Selector" rel="{handler:'iframe', size: {x: 800, y: 460}}" href="index.php?option=com_k2&amp;view=users&amp;task=element&amp;tmpl=component">
<i class="fa fa-pencil"></i>
</a>
<input type="hidden" name="created_by" value="<?php echo $this->row->created_by; ?>" />
<?php endif; ?>

Maybe, changing it with the right parameters (backend use "row", and frontend usually work with "item"), it would work, but I don't know, I guess it's necessary some more code, because K2 doesn't give that permission to frontend.

I guess after making the changes, you would have to insert the code and add it in the right (maybe it's the itemform.php).

You can always try safelly with templates, but don't hack the code.

If someone has any other hints, maybe you can go further.

I can't test it now, and I actually don't use editform in frontend in my websites, so I can't give you the details.

Best luck!

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 2 weeks ago #157729 by Krikor Boghossian
Replied by Krikor Boghossian on topic Changing author on frontend edit form
$this->mainframe->isSite() && $this->permissions->get('editAll')

Means that you only have access to this field if the user can edit all items.

Now, the file is indeed itemform.php, just make sure to use overrides. getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum