I have in the code I don't conrol such a line which returns false:

if (!$user->authorise('core.create', 'com_jdownloads.category.'.$option->value)) {

I can run my code before and after this line (via a plugin).

I need to temporary allow user to permit the action currently banned with the code above, and after done, and change permissions back.

Is this possible and how?

========= Long story upon @Irata request

@Irata I'm a developer of extension, which sends email notifications on Joomla content update - NotificationAry (NA), https://extensions.joomla.org/extension/notificationary/

Though it mainly works with JDownloads, I meet a problem reported by a user. NA allows users to subscribe per category and in User profile one can check categories to be notified on changes in. Screenshot: http://images.my-dev.org/x/2020_07_18_16_32_52_nn.png

This works in backend, but fail at frontend. http://images.my-dev.org/x/2020_07_18_16_34_51_vq.png

To generate a list of JDownload categories I use your field /administrator/components/com_jdownloads/models/fields/jdcategoryselect.php

In my code it looks like this: https://github.com/gruz/GJFields/blob/master/categoryext.php#L196 But at frontend it always returns empty array of options. At least now. It was ok some time ago, but maybe years ago.

I checked JDownloads code and it doesn't allow registered users to get categories list administrator/components/com_jdownloads/models/fields/jdcategoryselect.php Line about 115

if (!$user->authorise('core.create', 'com_jdownloads.category.'.$option->value)) {

So at Frontend a registered user is not able to get the list of categories.

I want to get the list of your categories and to use native JDownloads field for this. I try to avoid copying other extensions code into mine because updates can break things. I had to copy JDownloads code, https://github.com/gruz/GJFields/blob/master/categoryext.php#L199 to make it work dirty

  • Can you share more of the code around the position you want to override and the code you want to override it with. This looks like very normal code to check the authorisation of a user so it is unlikely a plugin is triggered anywhere near it to be helpful to you. There is nothing in the list of core events that looks like it will help you either, docs.joomla.org/Special:MyLanguage/Plugin/Events
    – Irata
    Jul 19, 2020 at 9:44
  • If you can't alter the code listed then you probably can't override the authorise method of the $user object to make an exception for your user to to return a true that allows your desired user to bypass the access control. Maybe you need to rethink what you are trying to do.
    – Irata
    Jul 19, 2020 at 9:48
  • @Irata Comment doesn't allow to post the details you require. So I added it to the question for you Jul 19, 2020 at 10:38
  • What you currently have is better than trying to hack core Access library.
    – Sharky
    Jul 19, 2020 at 16:56
  • @Sharky I'd never hack core libraries. And I don't recommend you do to it as well. Jul 19, 2020 at 17:24

1 Answer 1


You are overcomplicating things. Creating your own field class is the correct solution and you should remove the use of JFormFieldjdCategorySelect completely.

  • What if later the thirdparty developer changes his field logic? I must then at first be aware of it (which is not possible, till some user reports that two extensions stop working together) and next I have to reimplement the code from the the other extention in my code again. What you say is to copy-paste code of another extension into mine instead of reusing it. I think you don't understand what I want. I reuse select Categories fields from other extensions in my extension, trying to avoid per-extension logic as much as possible. Jul 20, 2020 at 7:17
  • That code, as you already noticed, is not suitable for your use case. What else is there to add? Trying to workaround core permission checks is the unnecessarily complex solution. Meanwhile the code you need is just a simple query against category table. It would only break if JDownloads decide to make breaking changes in their database structure which is not very likely for this specific table.
    – Sharky
    Jul 20, 2020 at 7:46
  • If there were a way to write smth. like $origperm = $user->get('some.perm'); $user->setperm('some.perm', true); and then after my code executed bring it back like $user->setperm('some.perm', $origperm); it would be better then copy/paste JDownloads code. If my question has negative answer, the only copy copy/paste (in fact done before your first comment, check git). You don't know if it's possible, ok. I'd better want to hear that it's not possible and there is no other way except copy-pasting, then discussing ... nothing. Anyway, thanks for your efforts to help. Jul 20, 2020 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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