Skip to content

Plugin Development

Have a question about building a plugin? Ask here
424 Topics 1.9k Posts
  • How to change user name via external call?

    3
    0 Votes
    3 Posts
    451 Views
    Brutus5000B

    Thank you very much @oplik0 for your very detailed and helpful answer. 👍 I will take a look into the write-api plugin first and see how far I get. From your description it sounds like what I need.

  • 0 Votes
    4 Posts
    3k Views
    sazuloS

    The real error was due to the fact that I wrote callbackUrl instead of callbackURL when pushing into the strategies.

    And, as I'm developing with version 1.12.2, I can't just return the results as this version does not support promises.

  • How to change custom user variables?

    3
    0 Votes
    3 Posts
    428 Views
    oplik0O

    You have to create an acp page for managing your plugin.
    For a basic example just look at how the quickstart plugin implements its panel, and look for plugins that have a panel similar to what you want to do.

  • How to use local JS files in ACP script

    1
    0 Votes
    1 Posts
    210 Views
    S

    Hi,

    How to require local utilities in my acpScript properly? I want to separate functions in my acpScript of my plugin into several JS files. My acpScipt is located at path public/lib/admin/index.js with codes:

    'use strict'; /* globals socket, define, require */ define( 'admin/plugins/myPlugin', [ 'myAdminUtilities' ], function (util) { const Admin = {}; Admin.init = function () { socket.emit( 'plugins.myPlugin.getData', myAdminUtilities.handleResponse, ); }; return Admin; } );

    Then, file myAdminUtilities is located at path public/lib/admin/utils.js with codes:

    define('admin/plugins/myAdminUtilities', function () { const adminUtils = {}; adminUtils.handleResponse = function (error, data) { // process data ... }; return adminUtils; });

    Also, I have modified my plugin.json with following:

    { ... "modules": { "myAdminUtilities": "public/lib/admin/utils.js" }, ... }

    But, I get get admin/plugins/myAdminUtilities (404 Not found) every time I enter my plugin ACP page. What's the proper way to reach my goal?

  • looking for plugin developers

    1
    0 Votes
    1 Posts
    220 Views
    G

    I am looking for plug-in developers to help develop plug-ins for a project, please explain to me the basics of building a plug-in and interacting with users through the admin panel

  • 0 Votes
    5 Posts
    567 Views
    A

    Success ! I have been able to implement spectrum as a button in composer without using addButtonDispatch. Ouf !

  • More group badges

    9
    0 Votes
    9 Posts
    2k Views
    barisB

    For anyone looking at this, there is no need to load the members of the groups so this code should work fine.

    library.modifyUserInfo = function(userData, callback) { var groupsData; async.waterfall([ function (next) { groups.getUserGroups([userData.uid], next); }, function (_groupsData, next) { groupsData = _groupsData[0]; userData.groups = groupsData.filter(Boolean); next(null, userData); }, ], callback); }
  • Append templateData to sidebar

    5
    1 Votes
    5 Posts
    626 Views
    magnusvhendinM

    @baris Just what I needed. Thanks a lot!!

  • 0 Votes
    3 Posts
    511 Views
    6676

    Wow! So turns out it was a silly error on my part. I had tried the Error object previously, but it was while looking at a different part of the code... I was actually looking/changing the 'imagekit' case in the code and being stumped as to why I was still seeing the behavior as I explained. Anyhow, it is working as it should when passing in an Error object. Thanks for the extra insight!

  • 0 Votes
    3 Posts
    425 Views
    julianJ

    If you are using SSL on your site (which you should), then the <input type="password"> is sufficient, as the payload is encrypted in-transit.

  • 1 Votes
    5 Posts
    2k Views
    oplik0O

    I was interested in that functionality as well, so I developed my own version of it.
    It can be found here and already is in nbbpm (can be installed from ACP by searching for nodebb-plugin-category-queue)
    It has some basic ACP (list of categories with options to queue new topics from them or not queue), and only works on new topics, not all posts (that is actually by design, as - after all - you have done the work on filtering posts already. It's just that I was looking for only sending new topics to queue)

  • Discord widget

    3
    2 Votes
    3 Posts
    599 Views
    Y

    @Jean-baptiste-Devic Unfortunately no, because discord api does not return the role.

  • Proper way to return res.redirect('')?

    8
    0 Votes
    8 Posts
    1k Views
    J

    @Joykiller said in Proper way to return res.redirect('')?:

    @julian said in Proper way to return res.redirect('')?:

    Callbacks don't work all that nicely with async functions... I think stripe.subscribe is called with await and returns undefined before the isValueID method is called and returns.

    I added asyncs to test, removed them same issue with headers response from res.redirect. Oh i see what this plugin does, I guess i could write it to the session and then call it from there. Argh im at a loss that didnt work either still same header issue. seems like even the other values prob would do the same as mine I duno if the way it was coded from base was correct.

    Nevermind I got it working with writing to the session first, had an error on previous attempt.

    Thanks for the help.

  • NodeBB and Apollo GraphQL

    3
    0 Votes
    3 Posts
    603 Views
    S

    @julian thanks for your reply.

    The reason why I inject Apollo as a middleware is because of the server integrate document on Apollo website shows that we can use the apollo-server-express package to integrate GraphQL with existing Express server by adding following code:

    server.applyMiddleware({ app }); // app is from an existing express app

    Does router will be the express app to be passed to plugins? Because I solved this problem by passing router into .applyMiddleware() method as following changes:

    const router = params.router; apolloServer.applyMiddleware({ app: router, path: '/api/mygraphql', });

    Now, the GraphQL works fine on my NodeBB server ! Hope this can help someone who run into the same problem like me. Although it looks like GraphQL is not popular in NodeBB community 🤔.

  • Stripe Subscription Plugin

    5
    5 Votes
    5 Posts
    2k Views
    J

    @psychobunny Pinging you since this is a fork of your plugin for paypal.

    Ok so, Update 1:
    Removed the function onload wrapper. Still same problem as above, however step closer, Now clicking the navigation once more loads the GET files. But doesnt do it on initial visit from navmenu.

    I guess a quick fix would be to just have it refresh or reload page when visiting it, but that isnt good i dont think.

    UPDATE 2: SOLVED.. Nevermind its not solved. Some times it works some times theres a delay and still never gets sent..

    Found another bug.. You may call me the bug hunter. 😄
    https://github.com/edthefifth/nodebb-plugin-stripe-subscriptions/blob/master/library.js line 90 - Getting an error i assume due to the template not entirely sure about this one.

    ajaxify.js in console brings up the following..
    7f8febd0-20fd-4704-b9dd-2b783675586d-image.png

    So if you're subscribed, then go back to visit the Subscribe link in navmenu, the loading bar will continue to spin but not load or /redirect you. Unless you refresh.

  • Change forum collection information (Solved)

    2
    0 Votes
    2 Posts
    418 Views
    PitaJP

    You can customize translations using nodebb-plugin-customize

  • Database not updating field

    2
    0 Votes
    2 Posts
    313 Views
    Lucas RomierL

    Hello everyone,

    I am trying to save a nested JSON array into my database.

    I init my database entry as following:

    Database.getObject('nodebb-plugin-europahaus-addon-spotify', function (data) { if (!data) { //Init as default and save to database data = { currentTrack: "", playlistSongs: [], requestedSongs: [], playback: false } Database.setObject('nodebb-plugin-europahaus-addon-spotify', data, function(err) { if (err) console.error(err); }); });

    which adds the data perfectly fine.

    Now I want to edit one of the fields.

    Therefore, I use the following code:

    songs = []; //Add songs and information tracks.forEach(function(track) { var artistsString = ""; track.track.artists.forEach(function(artist) { artistsString += artist.name + ", "; }); artistsString = artistsString.slice(0, -2); songs.push({ track: { id: track.track.id, name: track.track.name, artists: artistsString, uri: track.track.uri } }); }); //Save data in database //https://community.nodebb.org/topic/824/communicating-with-the-database/3 //Save JSON as string since NodeBB won't allow saving arrays Database.setObjectField('nodebb-plugin-europahaus-addon-spotify', 'playlistSongs', songs, function(err) { if (err) console.error(err); callback(null, {can: true, tracks: songs}); });

    When accessing my database, no value has changed. Even when replacing the array by a simple string, no update occurs in the database.

    Thank you for your help!
    Kind regards.

  • nodebb--plugin-sso-ldapauth

    3
    0 Votes
    3 Posts
    570 Views
    M

    Hi.

    Maybe this helps? sso-open-ldap

  • OpenLDAP Plugin with Group Sync

    1
    0 Votes
    1 Posts
    316 Views
    M

    Hi!

    I wrote a plugin for OpenLDAP.
    It overrides the default login and falls back to local login if the user is not found in LDAP.
    It also creates all groups found in LDAP and automatically joins the user into them.
    Using it as an alternative login is not implemented as I couldn't figure it out quick enough. It should be easy to do - feel free to add a pull request.

    The source is on github. Pull requests are welcome!
    Please be kind, my JavaScript skills are limited.

  • 1 Votes
    3 Posts
    756 Views
    MostHatedM

    I appreciate the reply. It looks like after a bunch of tinkering, it seems to be working. I put the plugin into one of the persistent folders, then made a script that I execute via Docker-Compose just before I call grunt which handles the actual linking and then it showed up.