Please or Register to create posts and topics.

Show hide forum after certain number of messages

Hello!

 

How possible to show hide forum only when member will post for exampe 10 or any other amount of messages!?

 

Maybe some addons?

Hey @biska7,

I will probably add this functionality also to my plugin later.

For now you can create a usergroup and assign a category to this usergroup.

To add users automatically to the usergroup after posting a specific number of posts you can use the following code:

add_action('asgarosforum_after_add_topic_submit', 'check_posts', 20, 6);
add_action('asgarosforum_after_add_post_submit', 'check_posts', 20, 6);

function check_posts($post_id, $topic_id, $subject, $content, $link, $author_id){
    global $asgarosforum;
    $count_posts = $asgarosforum->countPostsByUser($author_id);
    // The IDs of the usergroups to add
    $add_group_ids = array(22);
    // Minimum posts
    $min_posts = 10;

    if ($count_posts > $min_posts){
        // Get UserGroups
        $user_groups =  AsgarosForumUserGroups::getUserGroupsOfUser($author_id);
        $user_groups_ids = array();

        foreach ($user_groups as $user_group){
            $user_groups_ids[] = $user_group->term_id;
        }

        // Check if usergroups are already given to user
        if (!empty(array_diff($add_group_ids, $user_groups_ids))){
            $new_group_ids = array_merge($add_group_ids, $user_groups_ids);

            // Add user to group(s).
            AsgarosForumUserGroups::insertUserGroupsOfUsers($author_id, $new_group_ids );
        }
    }
}

 

Asgaros has reacted to this post.
Asgaros
If you ever wonder how to return the favour for helping you.