Is it possible to extend a controller in a V4 plugin?

System Information
  • Strapi Version: 4
  • Operating System:
  • Database: Postgres
  • Node Version:
  • NPM Version:
  • Yarn Version:

For example, I added passing an avatar file field to the users-permissions register method by copying the register method code from the users-permissions auth controller from the node_modules code and putting it in the strapi-server.js in src/extensions/users-permissions directory. For example:

module.exports = (plugin) => {
plugin.controllers.auth.register = async (ctx) => {
const pluginStore = await{ type: ‘plugin’, name: ‘users-permissions’ });
// my custom code

What I would rather do is call ‘super’ and only add my unique code around the plugin ‘core’ controller. Is this possible?

1 Like