• We've added extra Spam Protection. if you get problem with account registration / registration rejected. please contact us
  • You need minimum 5 good posts for download files. Don´t push posting-counter with posts copy paste, thx, good, smileys..... Read This.
  • Note: don´t push posting-counter with messages like thx, good, haha, only use reactions! threads will be deleted without any comment or notification. Read Rules.
XenForo

PHP Criteria 1.0.0

No permission to download
proxy.php?image=https%3A%2F%2Fwww.nulledteam.com%2Fdata%2FMetaMirrorCache%2Fxenforo_com_community_attachments_logo_png_163095__.png&hash=49dc7c7273417b6b5c844eef1ff0ab60

This addon allows you to create complex criteria for advanced trophies or user group promotions with custom PHP code.

For example, you can use:

  • Count the number of threads the user has created in specific forum
  • Analyze users signatures
  • Count the number of likes on single messages
  • Retreive data from addons (like Resource Manager or Question Threads)
  • See how many times (and when) user has edited his post
  • ...
In other words, this addon gives you a full access to xenForo engine and database when creating trophies/promotions.

Moreover you can even combine default xenForo criteria and your custom PHP code!

Your possibilities are limited only by your imagination!

Installation:
  1. Download an addon archive and unpack it somewhere
  2. Open upload folder and move src folder to your forum root directory
  3. In admin panel go to "Add-ons" section and install "PHP Criteria" addon
Thats it!
You can now create advanced trophies/promotions!

How to use:

When creating a new trophy/promotion you can see a new tab called "PHP Callback":
proxy.php?image=https%3A%2F%2Fwww.nulledteam.com%2Fdata%2FMetaMirrorCache%2Fxenforo_com_community_attachments_php_callback_tab_png_163088__.png&hash=92498168d49fb3ee9aac0834dfc3a725


This tab opens a pane where you can set a path to .php class and an exact method to be executed:

proxy.php?image=https%3A%2F%2Fwww.nulledteam.com%2Fdata%2FMetaMirrorCache%2Fxenforo_com_community_attachments_php_callback_pane_png_163089__.png&hash=c6174a5d313157918ce078364a925eeb


For example, according to the image above we need to create a file Criteria.php at src/addons with the following content:

PHP:
<?php

class Criteria
{
    public static function trophy_AllForOne(\XF\App $app, \XF\Entity\User $user)
    {
        //
        // YOU CUSTOM CRITERIA CODE GOES BELOW
        //

        // Getting the database
        $db = $app->db();

        // Database query for selecting the maximum number of likes for single user post
        $query = "SELECT `likes` FROM `xf_post` WHERE `user_id` = ? ORDER BY `likes` DESC LIMIT 1";

        // Retrieving the maximum number of likes
        $likes = $db->fetchOne($query, [$user->user_id]);

        // Checking that we have a result from database (we do expect a number)
        if(is_int($likes))
        {
            // Returning true if user has a message with 5 or more likes or false if he has not
            return ($likes >= 5);
        }
        else
        {
            return false;
        }
    }
}
Author
XenForo
Downloads
1
Views
65
First release
Last update
Rating
3.00 star(s) 1 ratings

More resources from XenForo

Top

AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock