I’m looking for a way to implement a category as a simple marketplace where users can purchase an ad (read post).
It looks like the subscriptions plugin will allow a paid addition to a group, and then when the subscription is cancelled, either manually or programmatically, it removes the user.
What I’m trying to accomplish is a subscription that will allow a post in a category and then remove them from the group allowed to post.
Can this be accomplished either just with the subscriptions plugin, or maybe between subscriptions and automation?
Said more simply, I want to sell individual posts. Replies to posts would be free.
Well, I can’t code myself, and since this would be a proof of concept before I could get my boss to support it I don’t have a way to offer any monetary support at this time.
Anyone else think something like this would be good for the community?
One other consideration, is there any communication between Discourse and the subscriptions plugin that could keep track of how many subs a user has? Would be helpful to allow someone to buy multiple posts at once rather than buy one, then post, then buy another then post again.
For sure, but would be cool to have.
Anyway, it looks like this would do the job as long as you hard code the category ID and group name.
Can any real coders expand on this so that you can set those variables from the plunin’s settings page?
# name: discourse-auto-remove-group
# version: 0.1
# authors: tknospdr
# url: https://github.com/tknospdr/discourse-auto-remove-group
enabled_site_setting :auto_remove_group_enabled
# Site setting to enable/disable the plugin
register_site_setting :auto_remove_group_enabled, type: :boolean, default: false
register_site_setting :auto_remove_group_category_id, type: :integer, default: 0
register_site_setting :auto_remove_group_name, type: :string, default: ""
after_initialize do
# Listen for post creation events
DiscourseEvent.on(:post_created) do |post|
next unless SiteSetting.auto_remove_group_enabled
next unless post&.user # Ensure post has a user
next unless post&.topic&.category_id # Ensure post is in a category
target_category_id = SiteSetting.auto_remove_group_category_id
group_name = SiteSetting.auto_remove_group_name
# Check if the post is in the configured category
if post.topic.category_id == target_category_id
begin
group = Group.find_by(name: group_name)
unless group
Rails.logger.error("AutoRemoveGroup: Group '#{group_name}' not found")
next
end
user = post.user
if group.users.include?(user)
group.remove(user)
Rails.logger.info("AutoRemoveGroup: Removed user #{user.username} from group #{group_name} after posting in category #{target_category_id}")
else
Rails.logger.info("AutoRemoveGroup: User #{user.username} is not in group #{group_name}, no action taken")
end
rescue StandardError => e
Rails.logger.error("AutoRemoveGroup: Error removing user from group: #{e.message}")
end
end
end
end
Both grok and ask.discourse.com say to install the plugin @ /var/discouse/plugins/.
Problem is that I don’t have that path, either inside or out of the container. The closest I can find is inside the container I have /var/www/discourse/plugins/.
When I try to install it there and rebuild, it disappears.
Okay, so the bot says that’s normal for a self hosted install. I don’t know how to set up a proper git repository in order to get the plugin installed the normal way. Can someone help me out with that?
Think I got git going, installed the plugin and got some errors. This is honestly where I’m lost.
/var/www/discourse/plugins/discourse-auto-remove-group/plugin.rb:9:in `activate!': undefined method `register_site_setting' for an instance of Plugin::Instance (NoMethodError)
You are unable to start Discourse due to errors in the plugin at
/var/www/discourse/plugins/discourse-auto-remove-group
Please try removing this plugin and rebuilding again!
I, [2025-05-20T16:17:10.306025 #1] INFO -- :
I, [2025-05-20T16:17:10.347496 #1] INFO -- : Terminating async processes
I, [2025-05-20T16:17:10.350251 #1] INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/15/bin/postmaster -D /etc/postgresql/15/main pid: 42
I, [2025-05-20T16:17:10.351238 #1] INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 109
2025-05-20 16:17:10.351 UTC [42] LOG: received fast shutdown request
109:signal-handler (1747757830) Received SIGTERM scheduling shutdown...
109:M 20 May 2025 16:17:10.368 # User requested shutdown...
109:M 20 May 2025 16:17:10.369 * Saving the final RDB snapshot before exiting.
2025-05-20 16:17:10.412 UTC [42] LOG: aborting any active transactions
2025-05-20 16:17:10.438 UTC [42] LOG: background worker "logical replication launcher" (PID 56) exited with exit code 1
2025-05-20 16:17:10.438 UTC [51] LOG: shutting down
2025-05-20 16:17:10.447 UTC [51] LOG: checkpoint starting: shutdown immediate
2025-05-20 16:17:10.526 UTC [51] LOG: checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.001 s, total=0.088 s; sync files=0, longest=0.000 s, average=0.000 s; distance=0 kB, estimate=4 kB
2025-05-20 16:17:10.540 UTC [42] LOG: database system is shut down
109:M 20 May 2025 16:17:10.947 * DB saved on disk
109:M 20 May 2025 16:17:10.947 # Redis is now ready to exit, bye bye...
FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 987 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params {"cd"=>"$home", "tag"=>"migrate", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
9fed9596b10ffb4628947e678585b813813ae27a4de746feba16e89f2b9cdc51