Question about the "after_add_….." hook
Quote from Lionear on November 27, 2017, 8:43 amHi there,
I use this forum for quite a while now and still love the simplicity of it.
We already use the following hooks:
- asgarosforum_after_add_thread_submit
- asgarosforum_after_add_post_submit
But now I something I haven’t figured out yet. As its possible in Asgaros to define who can see which forumcategory and if a forumcatagory is public (Access: Public or Moderator only).
If I add a paramater to the function I call in the hook I only get the post ID. How do I get the accessibility or the usergroup in that function?
Hi there,
I use this forum for quite a while now and still love the simplicity of it.
We already use the following hooks:
- asgarosforum_after_add_thread_submit
- asgarosforum_after_add_post_submit
But now I something I haven’t figured out yet. As its possible in Asgaros to define who can see which forumcategory and if a forumcatagory is public (Access: Public or Moderator only).
If I add a paramater to the function I call in the hook I only get the post ID. How do I get the accessibility or the usergroup in that function?
Quote from Asgaros on November 28, 2017, 7:44 pmHi Lionear,
first some info: With the upcoming version the hook asgarosforum_after_add_thread_submit will be renamed to asgarosforum_after_add_topic_submit. So dont forget to adjust your code. 🙂
Here is some example code which you can use to get more information about the current category:
function submit_info($postID, $topicID) { global $asgarosforum; $groupIDs = get_term_meta($asgarosforum->current_category, 'usergroups', true); // IDs of usergroups for category. // Can get more information about it with: // AsgarosForumUserGroups::getUserGroupBy($groupID) print_r('<pre>'); print_r($groupIDs); print_r('</pre>'); // Access level for category. $accessLevel = get_term_meta($asgarosforum->current_category, 'category_access', true); print_r('<pre>'); print_r($accessLevel); print_r('</pre>'); die(); } add_action('asgarosforum_after_add_topic_submit', 'submit_info', 10, 2);I know, this looks a little bit tricky and there is no well-documented API yet. I will try to add some better functions for this in a future release.
Hi Lionear,
first some info: With the upcoming version the hook asgarosforum_after_add_thread_submit will be renamed to asgarosforum_after_add_topic_submit. So dont forget to adjust your code. 🙂
Here is some example code which you can use to get more information about the current category:
function submit_info($postID, $topicID) { global $asgarosforum; $groupIDs = get_term_meta($asgarosforum->current_category, 'usergroups', true); // IDs of usergroups for category. // Can get more information about it with: // AsgarosForumUserGroups::getUserGroupBy($groupID) print_r('<pre>'); print_r($groupIDs); print_r('</pre>'); // Access level for category. $accessLevel = get_term_meta($asgarosforum->current_category, 'category_access', true); print_r('<pre>'); print_r($accessLevel); print_r('</pre>'); die(); } add_action('asgarosforum_after_add_topic_submit', 'submit_info', 10, 2);
I know, this looks a little bit tricky and there is no well-documented API yet. I will try to add some better functions for this in a future release.
Quote from Lionear on November 30, 2017, 10:44 amThanks for the snippet works like a charm!
I have added the new hook to the code so when the old one gets the deprecated state I can remove it :).
But how can I get the URL of the new topic / post because I want to create a bridge between Asgaros and Discord so I need it so I can post it.
Thanks for the snippet works like a charm!
I have added the new hook to the code so when the old one gets the deprecated state I can remove it :).
But how can I get the URL of the new topic / post because I want to create a bridge between Asgaros and Discord so I need it so I can post it.
Quote from Asgaros on November 30, 2017, 3:23 pmTo get the link to the new topic you can use:
global $asgarosforum; $link = html_entity_decode($asgarosforum->getLink('topic', $asgarosforum->current_topic, false, '#postid-'.$asgarosforum->current_post));For posts:
global $asgarosforum; $link = html_entity_decode($asgarosforum->get_postlink($asgarosforum->current_topic, $asgarosforum->current_post));
To get the link to the new topic you can use:
global $asgarosforum; $link = html_entity_decode($asgarosforum->getLink('topic', $asgarosforum->current_topic, false, '#postid-'.$asgarosforum->current_post));
For posts:
global $asgarosforum; $link = html_entity_decode($asgarosforum->get_postlink($asgarosforum->current_topic, $asgarosforum->current_post));