2

I can't override the controller of com_users (Joomla 3.4). (I want, if a manager can make user registration on the site after when he loged in.So I want to see the registration form, if I loged in the site.)

If I modify the original file, then it works fine, but I don't want to modify the original file. I tried 2 override plugins for this (MVC override, Override master). These plugins override the file, but after I click the registration button I get the following error message:

Fatal error: Cannot redeclare class UsersController in D:\wamp\www\mysite\components\com_users\controller.php on line 136

It's the same file. I modified the line class UsersController extends JControllerLegacy to this class UsersController extends UsersControllerDefault. Because I read this here. What is the difference? Why doesn't it work this way? :/

Adrian Heine
  • 4,051
  • 2
  • 30
  • 43
Sanzi
  • 21
  • 3

2 Answers2

0
  1. If you have the MVC override plugin installed be sure to have "Make Extendable" set to yes in the backend (Plugins: System - MVC Override)
  2. I advice you to put all overrides (html, code, etc.) in your template directory, so create the controller file as: templates/YOUR_TEMPLATE/code/com_users/controller.php
  3. Finally, in THIS controller file you override it like it was mentioned:
    class UsersController extends UsersControllerDefault {

This should do the trick.

Masaia
  • 21
  • 4
0

This happened to me also. The issue was the that I was also overriding a subcontroller (inside controllers folders)

I had to add

$bufferContent = str_replace('extends UsersController','extends UsersControllerDefault',$bufferContent);
$bufferContent = str_replace('require_once', '//require_once', $bufferContent);

after

$bufferContent = str_replace($originalClass,$replaceClass,$bufferFile);

This is a hack and will only work the com_user override. You need to change the first line to reflect your correct component class.