Jump to content

How can I programmatically subscribe a user to a topic?


Omri Amos

Recommended Posts

Hi,

I'm using REST API in order to allow users to post topics/posts to the forum from my website.
The topics/posts are created successfully, they are assigned to the users, and everything works great - beside one issue: after sending the topic/post, the user does not get subscribed to the topic (even if the user's default settings is to automatically subscribe to topics they reply in).

I wish that the REST API would automatically subscribe the user to the topic after posting the reply / creating a topic.
If it's not possible with the REST API (which seems to be the case) then I would love to hear any ideas about a workaround.

I don't mind even running a SQL query directly (so after the REST API call, I will perform the query to subscribe the user_id to topic_id), if that will be the only solution, but I was unable to easily find out where in the database this is actually saved...

Thanks

Link to comment
Share on other sites

Look inside applications/core/modules/front/system/notifications.php and/or system/Content/Item.php, search for core_follow inside the files. 

Weirdly enough they don't have a method for this, so they actually use raw database queries in both those places. 

Link to comment
Share on other sites

UPDATE: I was able to manually subscribe the user, but then I noticed another issue - when adding a post using the REST API, it does not SEND A NOTIFICATION to subscribed users.....

So now I also need to find a way to "send" the notification about this post to the subscribed users.... help? :)

UPDATE / EDIT:
My bad it seems to be working fine 
 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...