Recent Topics

If you want to limit the user's creating blog nums by user group , see here!

Started by on Jan 25, 2016 – Contents updated: Jan 25, 2016

Jan 25, 2016 15:37    

In my sitution, all users can create blogs, but considering the performance and speed, we need to limit the number of creating blogs.For example, part of users (as students) can only create one blog (someone may never create blog), part of users (as teachers) can create 2-3 blogs, and part of the user can create more. So it's very useful if we can limit the nums by user group. I found a way to do so, but it's a pity that it's a hack but not a plugin. So if someone can make it as a plugin would be much better.

1.At inc\collections\_collections.init.php lines: 449 ,add 'perm_createblog_nums'=>0, so it like this:

return $permissions = array( 'perm_api' => $permapi, 'perm_createblog' => $permcreateblog, 'perm_getblog' => $permgetblog ,'perm_createblog_nums'=>0);

At the same time , lines: 458, in function get_available_group_permissions(), add an array:

'perm_createblog_nums' => array(
				'label' => T_( 'Allow creating blog numbers'),
				'user_func'  => 'check_createblog_user_perm',
				'group_func' => 'check_createblog_group_perm',
				'perm_block' => 'blogging',
				'perm_type' => 'text_input',
                                'maxlength' => 2,
				'note' => T_( 'It takes effect when “Users can create new blogs for themselves” has been checked'),
				),

2. In inc\collections\collections.ctrl.php, lines 59, add

$current_User_PermCreateBlogNums = $current_User->get_Group()->get_GroupSettings()->get("perm_createblog_nums",$current_User->get("grp_ID"));      
                if($current_User_PermCreateBlogNums <= $current_User->get_num_blogs())
                {
                        $Messages->add( sprintf( T_('The number of blogs you have created is: "% s" has reached the limit.The upper limit is: "% s". '),$current_User->get_num_blogs(),$current_User_PermCreateBlogNums   ) , 'error' );
                        $redirect_to = param( 'redirect_to', 'url', $admin_url );
			header_redirect( $redirect_to );
                }

Jan 25, 2016 16:10

Thank you for the precise description of the use case. It makes perfect sense, we will add this to the core.

Jan 25, 2016 16:31

@fplanque wrote earlier:

Thank you for the precise description of the use case. It makes perfect sense, we will add this to the core.

It’s my pleasure!


Form is loading...

powered by b2evolution free blog software – This forum is powered by b2evolution CMS, a complete engine for your website.