Custom profile fields

Plugin Development
  • Is there a way todo this or must I write a plugin?

    Missing:

    Age
    Phone
    Gender
    Interests
    Occupation

    Must be more people that need this 😉

  • Right now you'd have to write a plugin, although it would be kind of cool to have a profile field editor in the ACP to add / remove fields as necessary

  • "it would be kind of cool to have a profile field editor in the ACP to add / remove fields as necessary" <-- yes, that is how it works in phpbb 🙂

    My first step is to get to know nodebb, then I want to migrate all my forums to it but i still missing features and the lack of knowledge at this moment 🙂

    But if we could add this as a feature request 😉

  • Hello guys, I'm going to create custom-fields plugin. 😉

    Is any documentation about templates in use? Particulary I'm interested in augmentation of template outputs by plugins. First of all I would like to provide custom fields for the user (declared in acp) on page: /user/:username/edit

  • You would probably have to write a new hook and then loop through your custom data in the template. Feel free to send a PR to core/vanilla/persona or let us know if you run into trouble

  • @Nicolas , there is a plugin from Erlgo which should provide the functionality, but even after a tremendous amount of hacking around, I can't get it to work at all. Then again, I have a PHP background and only basic knowledge of NodeJS yet, so you might be able to make something out of it 🙂

    You can find the repo here:
    https://github.com/erlgo/nodebb-plugin-profile-extends

    I would be so glad if we had profile fields, my users keep bugging me 😉

  • @psychobunny is there any option to include plugin client js only for /account/edit endpoint?

    Also, Do you have an ideas, how to augment template for the plugin use - templates/account/edit.tpl? I need add dynamic set of fields to the template, Vanilla's account-edit template is 3 column layout (md:2-5-5), I would like to have (md: 2:4:3:3). Main problem here, that I can't find really abstract approach, solution will be very dependent on Theme... One solution, just replace template on app startup, another option, create set of regexps and try to change template or dom manipulation to get another set of columns. Anyway I'm looking for less dependent solution, so It will not brake with every release of the theme and easily work with another themes

    Taking everything into consideration, I will swap edit.tpl and include client js with a template just as script tag. But maybe you have better ideas 😉


Suggested Topics


  • 0 Votes
    8 Posts
    628 Views

    @julian I have a block with a code in my profile, but the markdown does not work for a block with a code, only for plain text44d40b8f-0553-4ce2-b67f-7363edb19dc2-image.png

  • 0 Votes
    1 Posts
    139 Views

    Hi all!
    I was wondering if there's a simple way to add my custom fields (from the ns-custom-fields plugin) to the regular edit.tpl. I'm making a private forum aimed at professionals and would really love it if I could have everything in one place.

    What I'm currently looking to add is Company, Title and possible some more in the future.

    An idea I have is to just put them in the available form and then using the custom-fields "API" in the backend (on save) to store them separately.

    Any ideas are welcome.

    Sorry to tag you (@Nicolas, the creator) but I believe you can answer this question quite easily.

    Thanks!

  • 0 Votes
    3 Posts
    340 Views

    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.

  • 0 Votes
    2 Posts
    238 Views

    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.

  • 0 Votes
    2 Posts
    1k Views

    @Thadeusz-Lay don't think there are hooks to do that. You can accomplish it by adding some js and css in ACP -> Appearance -> Custom HTML & CSS.

    Here is an example. You will need to add code to handle what needs to happen on clicking the button.

    Custom Header:

    <script type="text/javascript"> $(document).ready(function() { $(window).on('action:ajaxify.end', function(ev, data) { $('[component="account/cover"] .avatar-wrapper').append('<button class="btn-new"><i class="fa fa-plus"></i></button>'); }); }); </script>

    Custom CSS:

    .avatar-wrapper .btn-new { height: 2em; width: 2em; line-height: 2em; border-radius: 50%; border: none; background: #F44336; color: #fff; overflow: hidden; top: 93px; left: 4px; position: absolute; }