MyBB Community Forums

Full Version: Help with Post Count/New Reply and javascript alerts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
OK, I am attempting to make a "No Links in Post until certain number of posts" plugin.

Well, I edited class_parser.php, and added a few things. Using $mybb->user['postnum'] I stopped users from viewing links unless they have a certain number of posts. But I want them able to view links, just not post them.

So, is there an easy way to change it?

Or else, what file do I edit for a new post, so I can run a function when the "submit" button is pressed?

And how do you make Javascript alerts in PHP? I tried echo" <script...etc"


Thanks a heap,

BP
You can remove them when they post in inc/datahandlers/post.php

Inside the verify_message() method, after
$post['message'] = trim($post['message']);
...you can do something like this:
$poster = get_user($post['uid']);
if($poster['postnum'] < 50)
{
    $message = preg_replace('#\[url\=(.*?)\](.*?)\[/url\]#si', '', $message);
}
Alternatively you can stick this in the datahandler_post_insert_post or datahandler_post_update_post plugin hooks, but instead of $message, you would use
function yourplugin($handler)
{
    $poster = get_user($handler->post_insert_data['uid']);
    if($poster['postnum'] < 50)
    {
        $handler->post_insert_data['message'] = preg_replace('#\[url\=(.*?)\](.*?)\[/url\]#si', '', $handler->post_insert_data['message']);
    }
}


Javascript alert:
<script type="text/javascript">
alert('Hello world');
</script>