Jump to the post that solved this thread.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solved: 4 Months ago How to allow only active users to post a new thread
#1
Solved: 4 Months ago
Hello,

sorry for my English,

i want to allow only member have move than 4 threads can only post a new thread and if the members threads less than 5 i want when he click the New thread button he got a message " can't post new thread because you should write at least 5 threads in other forums ", or button for New thread is invisible for him.

i tried edit this function in forumdisplay.php
if( $foruminfo['fid']!=2)
{
if($foruminfo['type'] == "f"  && $foruminfo['open'] != 0 && $fpermissions['canpostthreads'] != 0 && $mybb->user['suspendposting'] == 0)
{
	eval("\$newthread = \"".$templates->get("forumdisplay_newthread")."\";");
}
}

its hide the button for post new thread in this forum but i want allow the button appear for users have threads more than 4 threads 
i tried this code

if($foruminfo['fid']==2 && $user['threadcount']>4)
{
if($foruminfo['type'] == "f"  && $foruminfo['open'] != 0 && $fpermissions['canpostthreads'] != 0 && $mybb->user['suspendposting'] == 0)
{
	eval("\$newthread = \"".$templates->get("forumdisplay_newthread")."\";");
}
}

but its not working can you help me with this
Edit : this is for special forum this froum id = 2 not for all forums the user can post new thread in other forums normal
Reply
#2
Solved: 4 Months ago
How can a user make atleast 4 threads if he is not allowed to make threads at the first place?

If you want to modify the criteria to 4 replies before gaining ability to make threads then promotion system is what you are looking for, no need to mess with core codes.
[Image: dehibernate.png]
Reply
#3
Solved: 4 Months ago
(08-13-2018, 06:33 AM)eskandrany Wrote: Hello,

sorry for my English,

i want to allow only member have move than 4 threads can only post a new thread

How are the members going to get the 4 required threads, if they "CANT CREATE A NEW THREAD" if they "HAVE under 5 THREADS" ?

* maybe you meant "4 POSTS" before being able to "start a new THREAD" ?

Create a NEW User Group - example name: Verified
* Copy permission from REGISTERED user Group.

Go to USERS & GROUPS > GROUPS >click the OPTIONS in the REGISTERED users column and select EDIT GROUP

Click FORUMS and POSTS tab ,
under Posting/Rating Options UNCHECK ( can post new threads )

scroll down and SAVE USER GROUP..

Now, on left side of click GROUP PROMOTIONS > ADD NEW PROMOTIONS ( tab )

Give it a Title and description: example: Verified

Under Promotion Requirements select POST COUNT

now scroll down and under POST COUNT menu put 4 .. and leave the option GREATER THAN

scroll down and under Original User Group, check REGISTERED

next, under New User Group, select Verified

next scroll down and click SAVE PROMOTION

* So when the Registered user has more than 4 post they are able to create a thread
Huh
Reply
#4
Solved: 4 Months ago
(08-13-2018, 07:01 AM)effone Wrote: How can a user make atleast 4 threads if he is not allowed to make threads at the first place?

This is in just special forum not all forums the forum which i want to not allow id =2 but other forums he can post new threads

(08-13-2018, 07:06 AM)v_2 Wrote: This is in just special forum not all forums the forum id =2 but other forums he can post new threads

can you please tell me the code for user thread count i will edit it like that if the forum id = 2 and the total threads of user's posts > 4 show the button for post new thread like that 
if( $foruminfo['fid']!=2 || ($foruminfo['fid']==2 && $memprofile['threadcount']>=5 ))
{
if($foruminfo['type'] == "f"  && $foruminfo['open'] != 0 && $fpermissions['canpostthreads'] != 0 && $mybb->user['suspendposting'] == 0)
{
	eval("\$newthread = \"".$templates->get("forumdisplay_newthread")."\";");
}
}

can you correct this code for me to hide the post new thread for users have threads less than 5 in forum id =2
Reply
#5
Solved: 4 Months ago
Open 'newthread.php' go to line around 93 and locate this code:

// Check if this forum is password protected and we have a valid password
check_forum_password($forum['fid']);

Add the following code just BEFORE it:

$allowedfid = 2;
$minthreadcount = 4;

if($fid != $allowedfid && (int)$mybb->user['threadnum'] < $minthreadcount )
{
	error_no_permission();
}

Change the variable values $allowedfid, $minthreadcount as per your need.
Done.

Note: I will still recommend to use a custom simple plugin for this. This is a very nasty kind of core edit (we don't place vars like that, we drive through settings) and I will not suggest it.
[Image: dehibernate.png]
Reply
#6
Solved: 4 Months ago
If you want to restrict one forum then:

$restrictedfid = 2;
$minthreadcount = 4;

if($fid == $restrictedfid && (int)$mybb->user['threadnum'] < $minthreadcount )
{
	error_no_permission();
}

For multiple restricted forums:

$restrictedfids = array(2, 3, 4);
$minthreadcount = 4;

if(in_array($fid, $restrictedfids) && (int)$mybb->user['threadnum'] < $minthreadcount )
{
	error_no_permission();
}
[Image: dehibernate.png]
Reply
#7
Solved: 4 Months ago
(08-13-2018, 08:36 AM)effone Wrote: If you want to restrict one forum then:

$restrictedfid = 2;
$minthreadcount = 4;

if($fid == $restrictedfid && (int)$mybb->user['threadnum'] < $minthreadcount )
{
	error_no_permission();
}

Thank you very much effone that what i need but please can you tell me how them get message to tell them that error because them have less than 4 threads in other forums .
Reply
#8
Solved: 4 Months ago
So you need a custom error message?
[Image: dehibernate.png]
Reply
#9
Solved: 4 Months ago
(08-13-2018, 09:58 AM)effone Wrote: So you need a custom error message?

yes i want message to tell them about this error like " you can't post new thread till your threads less than 4".
Reply
#10
Solved: 4 Months ago
OK. Change the code to:

$restrictedfid = 2;
$minthreadcount = 4;

if($fid == $restrictedfid && (int)$mybb->user['threadnum'] < $minthreadcount)
{
	error($lang->sprintf($lang->error_threadcountrestrict, $minthreadcount));
}

Open 'inc/languages/english/newthread.lang.php' and add this line at the end of the file:

$l['error_threadcountrestrict'] = "You are not allowed to create new thread in this forum unless you make atleast {1} threads in total.";

Save both files and you are good to go ...

Note: If you are not using english language then locate the language file under the suitable language directory you are using.
[Image: dehibernate.png]
Reply
Jump to the post that solved this thread.


Forum Jump:


Users browsing this thread: 1 Guest(s)