How do I make customizations to a plugin

Technical Support

Suggested Topics

  • Help with my Custom Function

    Solved Technical Support
    0 Votes
    13 Posts

    @oplik0 yeah and if you don't want an upgrade script and just want to run some code that connects to the database to modify stuff or create reports etc. you can run custom script. These go in the nodebb folder and can be executed by node my_custom_script.js. Below is a template that we use frequently.

    /* globals require, console, process */ 'use strict'; const nconf = require('nconf'); nconf.file({ file: 'config.json', }); nconf.defaults({ base_dir: __dirname, views_dir: './build/public/templates', upload_path: 'public/uploads', }); const db = require('./src/database'); db.init(async (err) => { if (err) { console.log(`NodeBB could not connect to your database. Error: ${err.message}`); process.exit(); } await doSomethingUseful(); console.log('done'); process.exit(); }); async function doSomethingUseful() { console.log('global object', await db.getObject('global')); }
  • custom javascript error

    Technical Support
    0 Votes
    3 Posts

    Just a correction: it's not that you don't need the <script> - it's just illegal unless you're writing something like jsx. When run this will immediatly cause Uncaught SyntaxError: Unexpected token '<' - because everything you put in custom Javascript is already put into a <script> tag.
    If you want to include another script either use some kind of imports (for example es modules) that works inside JS, or put the <script src=""> tag in custom header instead.

  • 0 Votes
    8 Posts

    @baris Those are already updated on my side. So the developers need to bring out updates, right?

    Thank you - no more errors/warnings.

  • 0 Votes
    1 Posts

    Hello, just wondered if you could quickly point me in the right direction.

    I'm using the autoassigncategory plugin, however I would like it to auto remove the find/read permissions for newly created categories for guests and registered-public, do you know how I could do this or point me to the correct documentation?


  • 0 Votes
    4 Posts

    If you removed node_modules then you need to reinstall it using npm i nodebb-plugin-emailer-mandrill.

    The reason it doesn't show up in acp plugin list is because of the latest changes to nbbpm. See here for details.