# Subscribe to post an ad

**URL:** https://meta.discourse.org/t/subscribe-to-post-an-ad/366751
**Category:** Support
**Tags:** subscriptions, automation
**Created:** [May 19, 2025, 8:21pm UTC](https://meta.discourse.org/t/subscribe-to-post-an-ad/366751 "2025-05-19T20:21:17Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![tknospdr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tknospdr/32/529762_2.png) [@tknospdr](https://meta.discourse.org/u/tknospdr)
#### Post date: [May 19, 2025, 8:21pm UTC](https://meta.discourse.org/t/subscribe-to-post-an-ad/366751/1 "2025-05-19T20:21:17Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![tknospdr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tknospdr/32/529762_2.png) [@tknospdr](https://meta.discourse.org/u/tknospdr)
#### Post date: [May 19, 2025, 11:43pm UTC](https://meta.discourse.org/t/subscribe-to-post-an-ad/366751/4 "2025-05-19T23:43:28Z")

</div>

I believe this set of permissions would allow what I’m asking given that ‘marketplace’ is the subscription group.

 ![marketplace](https://global.discourse-cdn.com/meta/original/4X/9/5/0/950e51c44d3da58f9430378fbaa73a7c2157e2b9.jpeg)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 19, 2025, 11:46pm UTC](https://meta.discourse.org/t/subscribe-to-post-an-ad/366751/5 "2025-05-19T23:46:26Z")

</div>

I think you’d need a plugin that would remove them from the group when creating a topic in the ad category.

I don’t the the automation plugin will remove users from groups.

---

<div class="post-metadata">

### Author: ![tknospdr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tknospdr/32/529762_2.png) [@tknospdr](https://meta.discourse.org/u/tknospdr)
#### Post date: [May 19, 2025, 11:57pm UTC](https://meta.discourse.org/t/subscribe-to-post-an-ad/366751/6 "2025-05-19T23:57:23Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 20, 2025, 12:03am UTC](https://meta.discourse.org/t/subscribe-to-post-an-ad/366751/7 "2025-05-20T00:03:06Z")

</div>

> [@tknospdr](#):
>
> 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.

You’d just have to tell him to use his imagination for the proof of concept.

You could likely do it with webhooks and one of those webhook tools like zapier.

> [@tknospdr](#):
>
> Would be helpful to allow someone to buy multiple posts at once rather than buy one, then post, then buy another then post again.

It would make the plugin more complicated.

---

<div class="post-metadata">

### Author: ![tknospdr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tknospdr/32/529762_2.png) [@tknospdr](https://meta.discourse.org/u/tknospdr)
#### Post date: [May 20, 2025, 12:16am UTC](https://meta.discourse.org/t/subscribe-to-post-an-ad/366751/8 "2025-05-20T00:16:14Z")

</div>

> [@pfaffman](#):
>
> It would make the plugin more complicated.

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?

```plaintext
# 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

```

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 20, 2025, 12:22am UTC](https://meta.discourse.org/t/subscribe-to-post-an-ad/366751/9 "2025-05-20T00:22:12Z")

</div>

That could work!

Start with the Discourse-plugin-skeleton, make that your plugin.rb and maybe see what [Ask.discourse.com](http://Ask.discourse.com) can do to help.

And use `add_model_callback` instead of Discourse.event. You can look in the all\_the\_plugins repo for some examples.

---

<div class="post-metadata">

### Author: ![tknospdr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tknospdr/32/529762_2.png) [@tknospdr](https://meta.discourse.org/u/tknospdr)
#### Post date: [May 20, 2025, 2:28pm UTC](https://meta.discourse.org/t/subscribe-to-post-an-ad/366751/10 "2025-05-20T14:28:53Z")

</div>

Both grok and [ask.discourse.com](http://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?

---

<div class="post-metadata">

### Author: ![tknospdr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tknospdr/32/529762_2.png) [@tknospdr](https://meta.discourse.org/u/tknospdr)
#### Post date: [May 20, 2025, 4:49pm UTC](https://meta.discourse.org/t/subscribe-to-post-an-ad/366751/11 "2025-05-20T16:49:09Z")

</div>

Think I got git going, installed the plugin and got some errors. This is honestly where I’m lost.

```plaintext
/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)

```

```plaintext
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

```

---

<div class="post-metadata">

### Author: ![tknospdr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tknospdr/32/529762_2.png) [@tknospdr](https://meta.discourse.org/u/tknospdr)
#### Post date: [May 20, 2025, 7:19pm UTC](https://meta.discourse.org/t/subscribe-to-post-an-ad/366751/12 "2025-05-20T19:19:36Z")

</div>

Holy crap! After several more conversations with Ask Discourse and Grok. The plugin is now working.

I guess AI really _ **IS** _ useful sometimes.

It’s ugly, but confirmed to be working.

 ![The listing under Admin>Plugins](https://global.discourse-cdn.com/meta/original/4X/4/e/0/4e02baacfbdfe339d2cff83c642543a182af7fcd.jpeg)  
 ![Crude but workable settings.](https://global.discourse-cdn.com/meta/original/4X/4/8/8/4885388b071d5e0f56d6b8032ba2b48a2ce548fc.jpeg)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 20, 2025, 10:16pm UTC](https://meta.discourse.org/t/subscribe-to-post-an-ad/366751/13 "2025-05-20T22:16:12Z")

</div>

Do you have a development instance set up?

---

<div class="post-metadata">

### Author: ![tknospdr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tknospdr/32/529762_2.png) [@tknospdr](https://meta.discourse.org/u/tknospdr)
#### Post date: [May 20, 2025, 10:39pm UTC](https://meta.discourse.org/t/subscribe-to-post-an-ad/366751/14 "2025-05-20T22:39:55Z")

</div>

I don’t even know what that means. 🙂

---

<div class="post-metadata">

### Author: ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)
#### Post date: [May 20, 2025, 10:53pm UTC](https://meta.discourse.org/t/subscribe-to-post-an-ad/366751/15 "2025-05-20T22:53:37Z")

</div>

You should place the Github repository URL in your app.yml file, if you are running a production install.

The cloning method that you did works more for development installs, but I don’t think that is what you are running (since you are using launcher).

---

<div class="post-metadata">

### Author: ![tknospdr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tknospdr/32/529762_2.png) [@tknospdr](https://meta.discourse.org/u/tknospdr)
#### Post date: [May 20, 2025, 11:04pm UTC](https://meta.discourse.org/t/subscribe-to-post-an-ad/366751/16 "2025-05-20T23:04:45Z")

</div>

Ah yes, that’s what I did.  
I added a git clone line in the app.yml file and rebuilt in order to get things going.

---

<div class="post-metadata">

### Author: ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)
#### Post date: [May 20, 2025, 11:05pm UTC](https://meta.discourse.org/t/subscribe-to-post-an-ad/366751/17 "2025-05-20T23:05:16Z")

</div>

Glad you got it working!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 21, 2025, 12:22am UTC](https://meta.discourse.org/t/subscribe-to-post-an-ad/366751/18 "2025-05-21T00:22:34Z")

</div>

If you are going to develop a plugin then it’s 1000 times faster to set up a [Install Discourse for development using Docker](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009) or [Install Discourse on Windows for development](https://meta.discourse.org/t/install-discourse-on-windows-for-development/75149) or Linux or Mac.

It means you can edit a file and hit reload on your browser to see if it worked. Sometimes you don’t even have to reload.
