• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.2 Latest
Buy Hosting

How to create topic from plugin?

Scheduled Pinned Locked Moved Solved NodeBB Plugins
3 Posts 2 Posters 1.4k Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • olegO Offline
    olegO Offline
    oleg
    wrote on last edited by
    #1

    Hi guyes. I wont make automaticly publish system based on plugins, but i don't know how to create topic from plugins.

    1 Reply Last reply
    0
  • yariplusY Offline
    yariplusY Offline
    yariplus Community Rep
    wrote on last edited by
    #2

    Inside a plugin, you can call Topics.post()

    var Topics = require.main.require('./src/topics');
    
    var payload = {
    	cid: 1, // The category id
    	title: 'the post title',
    	content: 'some post content',
    	uid: 1, // The user posting the topic.
    	timestamp: Date.now() // When the post was created.
    };
    
    Topics.post(payload, function(err, data) {
    	if (err) console.log(err);
    });
    

    I copied this from here.
    https://github.com/NodeBB/nodebb-plugin-write-api/blob/master/routes/v1/topics.js#L20-L30

    olegO 1 Reply Last reply
    1
  • olegO Offline
    olegO Offline
    oleg
    replied to yariplus on last edited by
    #3

    @yariplus yeah, its work, thank you 👍

    1 Reply Last reply
    0

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development