Skip to content

Plugin Development

Have a question about building a plugin? Ask here
427 Topics 1.9k Posts
  • 0 Votes
    12 Posts
    672 Views
    barisB

    do I have to read the source for each object to learns its methods?

    Yes, you will have to read the source code to see what methods are available.

  • 2 Votes
    11 Posts
    1k Views
    julianJ

    @Yve-Salazar Are you still looking to distinguish between API calls via curl?

  • 1 Votes
    17 Posts
    1k Views
    Y

    @baris thanks! This was very helpful. @Sebastián-Cisneros and I really appreciate it.

  • app.user.groupTitle shows only one item in array

    11
    0 Votes
    11 Posts
    925 Views
    barisB

    That's not possible out of the box, you would have to write a plugin to set the groupTitle value to all the groups the user is a member of.

  • 0 Votes
    7 Posts
    810 Views
    magnusvhendinM

    @baris This worked like a charm. Thank you!

  • Unable to override scripts

    Solved
    4
    0 Votes
    4 Posts
    405 Views
    magnusvhendinM

    @julian This worked great. I did this in my main client file (like persona.js).

    require(['hooks'], (hooks) => { hooks.on('filter:script.load', (data) => { const replaceMap = { register: { target: 'forum/register', with: 'replacement/register', }, }; const replace = replaceMap[data.tpl_url]; if (replace) { const index = data.scripts.indexOf(replace.target); if (index > -1) data.scripts[index] = replace.with; else data.scripts.push(replace.with); } return data; }); });

    Then I can just add my scripts that I want to replace to the replaceMap object.

  • 0 Votes
    5 Posts
    512 Views
    Sebastián CisnerosS

    I guess the right one is this one

    filter:email.cancel

    accodring to nodebb documents

    const result = await Plugins.hooks.fire('filter:email.cancel', { cancel: false, // set to true in plugin to cancel sending email template: template, params: params, });

    right?

  • Composer custom field validation

    14
    0 Votes
    14 Posts
    1k Views
    Sebastián CisnerosS

    @baris Thanks for the help. I appreciate it.

  • ajaxify.data.users not containing all my users

    4
    1 Votes
    4 Posts
    516 Views
    Spin0usS

    Thanks to @julian we finaly found the problem.
    Here is the pull request.

    In fact, this bug only occurs when an administrator update a member profile.

  • Calendar plugin evades private forum plugin

    1
    0 Votes
    1 Posts
    202 Views
    E

    See GitHub for reference, https://github.com/LM1LC3N7/nodebb-plugin-private-forum/issues/4#issuecomment-1034840197

    Wondering if anyone has an idea why the calendar page is accessible when not logged in while using the private forum plugin.

  • Replacing core language key value

    3
    0 Votes
    3 Posts
    344 Views
    W

    @PitaJ No errors, I redid it from scratch and it worked, I must have done something wrong. Thank you.

  • 0 Votes
    3 Posts
    513 Views
    Sebastián CisnerosS

    @PitaJ said in How to call API from client side.:

    require(['api', 'translator'], (api, translator) => {
    // Your code here
    });

    genius! and fast reply!

  • 1 Votes
    1 Posts
    293 Views
    A

    After install "nodebb-plugin-sso-beer-qq", my server crashed and nginx return code 502.

    After reset all plugins, my server is back to normal again.

  • Hook on the server or client side?

    Solved
    2
    0 Votes
    2 Posts
    441 Views
    barisB

    Hooks that are fired on the server side are only available for use for plugins in their server side code. Same for client side hooks they are only available for use in the client side code of plugins.

  • javascriptEnabled set to true

    2
    0 Votes
    2 Posts
    267 Views
    julianJ

    @tobiasdossinger The real question here is why you need javascript enabled...

    I am 95% certain you came here because maybe a theme of yours you have suddenly stopped working, with a cryptic error about turning javascriptEnabled on, yes?

    In that case, you may want to audit your theme and figure out what exactly needs javascript in your LESS... there really is no reason to that I have come across... although I could be mistaken.

    In Persona's case, it was the .opacity() mixin, which was not required anymore, as opacity is well supported cross-browser now: https://github.com/NodeBB/nodebb-theme-persona/commit/e14d38b827591c9681a5fcd43ca4b206297eaff5

  • Get req username in server-side

    Solved
    4
    0 Votes
    4 Posts
    464 Views
    barisB

    You need to make your controller async for it to work.

    init: async params => { RouteHelpers.setupAdminPageRoute(params.router, '/admin/plugins/myplugin', params.middleware, [], async (req, res) => { res.render('admin/plugins/myplugin', { username: await User.getUserField(req.uid, 'username') }) }) }
  • Update user profile image

    2
    0 Votes
    2 Posts
    513 Views
    barisB

    I suggest using user.updateProfile to make these changes, since it updates the necessary sorted sets for email/fullname.

    You can use the same function to update the picture url as well.

    await User.updateProfile(callerUid, { uid: targetUid, uploadedpicture: url, picture: url, }, ['uploadedpicture', 'picture']);
  • custom plugin with custom POST url

    2
    0 Votes
    2 Posts
    555 Views
    julianJ

    @sebastián-cisneros In static:api.routes, you'll want to call controllerHelpers.setupAPIRoute to mount the route to the appropriate /api/v3/plugins mount point.

    You can see an example of how we do it in the quickstart plugin

  • How to use with require in admin.js

    Solved
    3
    0 Votes
    3 Posts
    459 Views
    Y

    @julian thanks!
    I successed with plugin socket https://community.nodebb.org/post/76984

  • 0 Votes
    4 Posts
    561 Views
    PitaJP

    You can set the templates directory to anything in plugin.json, I think it defaults to just templates if you don't specify.

    Link Preview Image nodebb-plugin-calendar/plugin.json at 4368fdca0ef99336fde9875ab600349a5b13e59c · pitaj/nodebb-plugin-calendar

    Fully-featured calendar plugin for NodeBB. Contribute to pitaj/nodebb-plugin-calendar development by creating an account on GitHub.

    favicon

    GitHub (github.com)

    Them you match the path from views, so it would be templates/emails where you put them.