Change user permissions programmatically on the fly

Joomla Asked by AHeavyObject on September 5, 2021

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),

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.

This works in backend, but fail at frontend.

To generate a list of JDownload categories I use your field

In my code it looks like this:
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
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, to make it work dirty

One Answer

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

Answered by Sharky on September 5, 2021

Add your own answers!

Related Questions

Disabling cache on specific part of page from above comment

2  Asked on September 14, 2020 by ruchika


Custom Category Field

1  Asked on August 18, 2020 by grant-g


How do I pass _JEXEC to a php file?

1  Asked on August 6, 2020 by firefighter


Ask a Question

Get help from others!

© 2023 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP