I want to use custom post type
Quote from maaztishi on May 3, 2019, 5:39 pmHow can I use this “Create topics for new blog posts in the following forum” function as Create topics for custom post type in the following forum
How can I use this “Create topics for new blog posts in the following forum” function as Create topics for custom post type in the following forum
Quote from Asgaros on May 3, 2019, 5:53 pmHello @maaztishi
If you want to create new topics for custom post-types you can add the following example code-snippet to your themes functions.php file:
add_action('transition_post_status', 'create_topic', 10, 3); public function create_topic($new_status, $old_status, $post) { global $asgarosforum; if ($post->post_type == 'MY_POST_TYPE' && $new_status == 'publish' && $old_status != 'publish') { $forumID = $asgarosforum->options['create_blog_topics_id']; $post_title = apply_filters('asgarosforum_filter_automatic_topic_title', $post->post_title, $post); $post_content = apply_filters('asgarosforum_filter_automatic_topic_content', $post->post_content, $post); if ($asgarosforum->content->forum_exists($forumID)) { $asgarosforum->content->insert_topic($forumID, $post_title, $post_content, $post->post_author); } } }Dont forget to replace the MY_POST_TYPE string with the post-type which you want to use.
Hello @maaztishi
If you want to create new topics for custom post-types you can add the following example code-snippet to your themes functions.php file:
add_action('transition_post_status', 'create_topic', 10, 3); public function create_topic($new_status, $old_status, $post) { global $asgarosforum; if ($post->post_type == 'MY_POST_TYPE' && $new_status == 'publish' && $old_status != 'publish') { $forumID = $asgarosforum->options['create_blog_topics_id']; $post_title = apply_filters('asgarosforum_filter_automatic_topic_title', $post->post_title, $post); $post_content = apply_filters('asgarosforum_filter_automatic_topic_content', $post->post_content, $post); if ($asgarosforum->content->forum_exists($forumID)) { $asgarosforum->content->insert_topic($forumID, $post_title, $post_content, $post->post_author); } } }
Dont forget to replace the MY_POST_TYPE string with the post-type which you want to use.
Quote from Asgaros on October 31, 2019, 5:25 pmHello @suryoes
You can use the insert_post function instead to create new posts instead of topics. But ensure that you provide all required information:
insert_post($topic_id, $forum_id, $text, $author_id = false, $uploads = array());
Hello @suryoes
You can use the insert_post function instead to create new posts instead of topics. But ensure that you provide all required information:
insert_post($topic_id, $forum_id, $text, $author_id = false, $uploads = array());