Show hide forum after certain number of messages
Quote from biska7 on September 18, 2020, 5:20 pmHello!
How possible to show hide forum only when member will post for exampe 10 or any other amount of messages!?
Maybe some addons?
Hello!
How possible to show hide forum only when member will post for exampe 10 or any other amount of messages!?
Maybe some addons?
Quote from qualmy91 on September 21, 2020, 7:49 amHey @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 ); } } }
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 ); } } }