2

I'm very new to Joomla (version3).

I have two registered users.

When any registered user is logged in they can see a new menu which contains an item to show the Articles list. This works as expected.

What I want to happen is to show only those articles written by the currently logged in use - so they can only see their own articles to view or edit etc.

Iv seen a number of methods - including one about making a new category module, but these do not work as expected, and all users can still see articles by other people.

Any guidance would be greatly appreciated. I have no problem editing files, I just have no idea which file to edit.

Many thanks

  • Did you try setting up permissions to work this around? – Alexandr Oct 27 '17 at 14:26
  • What user group are these users set to? Are these users seeing this new menu on the front-end or on the administration side? – Drew G Oct 27 '17 at 14:55
  • Permissions are default as is the user group. All users see the menu on the front end and have no access to the back end. – MaxVK Oct 27 '17 at 18:40
  • I have found a working solution - posted above as a comment - but am unsure how or if this question should be marked as solved. – MaxVK Oct 28 '17 at 9:15
  • THANK YOU sooo much Maxvk. I have been searching for this for so long and it will revolutionise what I'm building for my site. Just a note, as a newbie, I got stumped with the specific user id part, because I want any logged in user to only see the items they have created. I fiddled about with the code you supplied and it works. If it helps anyone: <?php if ($this->items[$i]->created_by == JFactory::getUser()->id) : ?> It works...I trust there's no problem with that? – Chris Dec 13 '17 at 22:48
1

As per the suggestion by Nisse Engström (Many thanks) Ill post my solution here:

Having hunted around for an answer to this question for quite a while I have found a working solution and post it here in the hope that others might find this helpful.

The objective was to allow logged in users to see an articles list which only included their own articles and those of the SuperUser - they should only be able to edit their own articles.

To make this work the setup is as follows:

Default Install and using the Protostar template.

Override the file: "com_content/category/default_articles.php"

Around line 135 you can see the following line:

foreach ($this->items as $i => $article)

Directly below this line I have added the following code (Note that user 232 is my SuperUser - yours may have a different ID):

if ($this->items[$i]->created_by == JFactory::getUser()->id || $this->items[$i]->created_by == JFactory::getUser(232)->id) :

This is closed again on line 261 with a standard 'endif'. Note that this is directly above the closing 'endforeach' that started around line 135.

The Result

Is precisely what I wanted to see. Logged in users can now only see their own articles (and those of the Superuser, although they cannot edit these), and can submit new articles.

With a little tweaking of permissions each user can now create, edit, publish and trash only their own articles.

I have no idea if this is the "Right" way to achieve this result, but it works exactly as I wanted it to, and I am more than happy for experienced users to show alternative methods.

Possible future issue

This code is fired as Joomla loads the list of articles and as such will be fired many, many times as more and more users create more and more articles. Perhaps this will cause a slow down?

Anyway.....

1

I just posted this answer to another question - which is not exactly the same but the requirements are very similar and fall under the same context, which is "Front-end Authoring".

That question is: Joomla! 3.8 - How to hide Publishing Tab in front end

So, in your case, you may also find useful this information and will be good to know your options and possibilities:

I am pasting my other answer here slightly modified:

Apart of any customizations - you could consider using 3rd party extensions.

There are 2 major types/categories of extensions that would be suitable for this:

  1. Front-end article management
  2. CCK integration

1. Front-end article management

Front-end article management extensions are designed to offer front-end authoring/moderation capabilities to Joomla.

JED categories:

Some extensions:

2. CCKs Integration

Briefly, using a CCK you can create your own content-kit/content-workflow. There are CCKs that can be integrated with Joomla articles and allow you to create your own forms and lists. For example, with Fabrik you can create menu-items for articles lists to show articles only of the current user. Deep permissions configurations are also possible with such extensions, opening many possibilities.

  • Indeed "the requirements are very similar and fall under the same contexT" because that is also my question and is related to what I'm doing! :) – MaxVK Oct 30 '17 at 6:56
  • I hadn't noticed that you were the same guy on that other question @MaxVK – FFrewin Nov 10 '17 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.