How to get post id inside 'asgarosforum_filter_post_content'
Quote from knulo on August 24, 2017, 7:29 pmHi folks,
I plan to extend Asgaros Forum:
- moderation
- notification on new posts
I want to hold moderator information outside and want to check with ‘asgarosforum_filter_post_content’, so I can display a message like ‘Have to release by moderator’ in case of new, unreleased posts. For lookup I need the post id.
Is there a possibility to retrieve current post id within filter function. As far as I know, only the content is provided as parameter.
*edit*
I tried ‘global $post’, but that points to the forum, not to the current entry. 🙁Thanks for help and regards
Knulo
Hi folks,
I plan to extend Asgaros Forum:
- moderation
- notification on new posts
I want to hold moderator information outside and want to check with ‘asgarosforum_filter_post_content’, so I can display a message like ‘Have to release by moderator’ in case of new, unreleased posts. For lookup I need the post id.
Is there a possibility to retrieve current post id within filter function. As far as I know, only the content is provided as parameter.
*edit*
I tried ‘global $post’, but that points to the forum, not to the current entry. 🙁
Thanks for help and regards
Knulo
Quote from Asgaros on August 24, 2017, 8:34 pmHello knulo,
maybe it would be an option to show an info under the post-content? In this case you could use this hook:
do_action('asgarosforum_after_post_message', $post->author_id, $post->id);
Hello knulo,
maybe it would be an option to show an info under the post-content? In this case you could use this hook:
do_action('asgarosforum_after_post_message', $post->author_id, $post->id);
Quote from knulo on August 24, 2017, 9:31 pmHello Asgaros,
thanks for your reply, but this is – in general – no option, because I would hide the original post-content in case of still not released by the moderator. But maybe I can combine the do_action (add_action in my code) and the filter and inside the assigned function of the filter do the filter stuff regarding to the informations retrieved by the action? I’ll try that idea…
*edit*
Owned: do_action is called after apply_filters…Any other ideas?
Regards
Knulo
Hello Asgaros,
thanks for your reply, but this is – in general – no option, because I would hide the original post-content in case of still not released by the moderator. But maybe I can combine the do_action (add_action in my code) and the filter and inside the assigned function of the filter do the filter stuff regarding to the informations retrieved by the action? I’ll try that idea…
*edit*
Owned: do_action is called after apply_filters…
Any other ideas?
Regards
Knulo
Quote from Asgaros on August 24, 2017, 10:12 pmI added the post-ID to the asgarosforum_filter_post_content-filter.
You can download the development-version here. It should be stable to use. This addition will be also included in the upcoming release.
I added the post-ID to the asgarosforum_filter_post_content-filter.
You can download the development-version here. It should be stable to use. This addition will be also included in the upcoming release.
Quote from knulo on August 24, 2017, 10:32 pmHeureka, found a solution (this code inside my plugin):
$postTxt = ''; function naFilterPost($txt) { global $postTxt; $postTxt = $txt; echo ''; } function naActionPost($authorId, $id) { global $postTxt; // do the moderation stuff $released = ... (true/false) if ($released) echo $postTxt; else echo 'Waiting be released...'; } add_filter('asgarosforum_filter_post_content', 'naFilterPost', 10, 1); add_action('asgarosforum_after_post_message', 'naActionPost', 10, 2);Tested: works…
Regards
Knulo
Heureka, found a solution (this code inside my plugin):
$postTxt = ''; function naFilterPost($txt) { global $postTxt; $postTxt = $txt; echo ''; } function naActionPost($authorId, $id) { global $postTxt; // do the moderation stuff $released = ... (true/false) if ($released) echo $postTxt; else echo 'Waiting be released...'; } add_filter('asgarosforum_filter_post_content', 'naFilterPost', 10, 1); add_action('asgarosforum_after_post_message', 'naActionPost', 10, 2);
Tested: works…
Regards
Knulo
Quote from knulo on August 24, 2017, 10:46 pmQuote from Asgaros on August 24, 2017, 10:12 pmI added the post-ID to the asgarosforum_filter_post_content-filter.
You can download the development-version here. It should be stable to use. This addition will be also included in the upcoming release.
Hi, Asgaros,
thank you very much for your great and rapid work: you made my day!
Regards,
Knulo
Quote from Asgaros on August 24, 2017, 10:12 pmI added the post-ID to the asgarosforum_filter_post_content-filter.
You can download the development-version here. It should be stable to use. This addition will be also included in the upcoming release.
Hi, Asgaros,
thank you very much for your great and rapid work: you made my day!
Regards,
Knulo