Please or Register to create posts and topics.

I want to use custom post type

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

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.

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

how about create create post forum?

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());

 

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!