PAULEM
8 years agoAdvisor
How to create a 'subscribe to board' button
 I have found this info on Create an email subscription to a board ... but I don't understand how to make use of it.  I wish to add a button to certain boards that will allow users to subscribe to the...
- 8 years agoYou don't need to change the permissions in to your community. Simplest way to do this in your community is to add below code to your to lithium endpoint. <#assign board_ID= http.request.parameters.name.get("forumId") /> <#assign subscribed=restadmin("/boards/id/${board_ID}/subscriptions/users/self/add?subscription.type=email")/>and use below Freemarker and Jquery code into your custom component and add this to your page. <#assign boardID = coreNode.id /> <button id="subscribe">Subscribe to this board</button> <@liaAddScript> 
 (function($) {
 $('#subscribe').on('click', function() {
 $.ajax({
 url: "/community/plugins/custom/community/community/endpoint_name",
 data: {'forumId':${boardID}},
 method: "POST"
 }).done(function(response) {
 // DO SOMETHING HERE
 }.fail(function() {
 // DO SOMETHING HERE
 }));
 });
 })(LITHIUM.jQuery);
 </@liaAddScript>and You can also modify the same code to Unsubscribe the board by changing "Id" selector of button in HTML and jQuery and use unsubscribe API call in endpoint .