HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Points for forum posts by Group

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#111811 (In Topic #22475)
TQ
Avatar

Honoured member

Hi Folks,

I would like to give points for forum posts made by members of a specific group (whilst all other group members receive no points for posts), is this possible?

The reasoning behind this is that I do not give points on a per-post basis to stop people posting useless rubbish in order to accumulate points to use for downloads but there is a specific group (Technical Advisor) that I always want to give points to, to save me having to read every post and manually award points.

If this can't be done by group, is there a way to do it on a per member basis?

TQ
Back to the top
 
Posted
Rating:
#111813
Avatar

Hi,

You'd need to do it with a code override of sources/points.php.

Try changing this function:

PHP code

/**
 * Get the total points in the specified member's account; some of these will probably have been spent already
 *
 * @param  MEMBER            The member
 * @return integer        The number of points the member has
 */
function total_points($member)
{
    if (!
has_specific_permission($member,'use_points')) return 0;

    global 
$TOTAL_POINTS_CACHE;
    if (
array_key_exists($member,$TOTAL_POINTS_CACHE)) return $TOTAL_POINTS_CACHE[$member];

    
$points_gained_posting=$GLOBALS['FORUM_DRIVER']->get_post_count($member);
    
$_points_gained=point_info($member);
    
$points_gained_given=array_key_exists('points_gained_given',$_points_gained)?$_points_gained['points_gained_given']:0;
    
$points_gained_rating=array_key_exists('points_gained_rating',$_points_gained)?$_points_gained['points_gained_rating']:0;
    
$points_gained_voting=array_key_exists('points_gained_voting',$_points_gained)?$_points_gained['points_gained_voting']:0;
    
$points_gained_cedi=array_key_exists('points_gained_seedy',$_points_gained)?$_points_gained['points_gained_seedy']:0;
    
$points_gained_chat=array_key_exists('points_gained_chat',$_points_gained)?$_points_gained['points_gained_chat']:0;
    
$points_posting=intval(get_option('points_posting'));
    
$points_rating=intval(get_option('points_rating'));
    
$points_voting=intval(get_option('points_voting'));
    
$points_joining=intval(get_option('points_joining'));
    
$points_per_day=intval(get_option('points_per_day',true));
    
$points_chat=intval(get_option('points_chat',true));
    
$points_cedi=intval(get_option('points_cedi',true));
    
$points_gained_auto=$points_per_day*intval(floor(floatval(time()-$GLOBALS['FORUM_DRIVER']->get_member_join_timestamp($member))/floatval(60*60*24)));
    
$points=$points_joining+$points_gained_chat*$points_chat+$points_gained_cedi*$points_cedi+$points_gained_posting*$points_posting+$points_gained_given+$points_gained_rating*$points_rating+$points_gained_voting*$points_voting+$points_gained_auto;

    
$TOTAL_POINTS_CACHE[$member]=$points;

    return 
$points;
}

to:

PHP code


/**
 * Get the total points in the specified member's account; some of these will probably have been spent already
 *
 * @param  MEMBER            The member
 * @return integer        The number of points the member has
 */
function total_points($member)
{
    if (!
has_specific_permission($member,'use_points')) return 0;

    global 
$TOTAL_POINTS_CACHE;
    if (
array_key_exists($member,$TOTAL_POINTS_CACHE)) return $TOTAL_POINTS_CACHE[$member];

    
$points_gained_posting=0;
    if (
in_array(123,$GLOBALS['FORUM_DRIVER']->get_members_groups($member)))
        
$GLOBALS['FORUM_DRIVER']->get_post_count($member);
    
$_points_gained=point_info($member);
    
$points_gained_given=array_key_exists('points_gained_given',$_points_gained)?$_points_gained['points_gained_given']:0;
    
$points_gained_rating=array_key_exists('points_gained_rating',$_points_gained)?$_points_gained['points_gained_rating']:0;
    
$points_gained_voting=array_key_exists('points_gained_voting',$_points_gained)?$_points_gained['points_gained_voting']:0;
    
$points_gained_cedi=array_key_exists('points_gained_seedy',$_points_gained)?$_points_gained['points_gained_seedy']:0;
    
$points_gained_chat=array_key_exists('points_gained_chat',$_points_gained)?$_points_gained['points_gained_chat']:0;
    
$points_posting=intval(get_option('points_posting'));
    
$points_rating=intval(get_option('points_rating'));
    
$points_voting=intval(get_option('points_voting'));
    
$points_joining=intval(get_option('points_joining'));
    
$points_per_day=intval(get_option('points_per_day',true));
    
$points_chat=intval(get_option('points_chat',true));
    
$points_cedi=intval(get_option('points_cedi',true));
    
$points_gained_auto=$points_per_day*intval(floor(floatval(time()-$GLOBALS['FORUM_DRIVER']->get_member_join_timestamp($member))/floatval(60*60*24)));
    
$points=$points_joining+$points_gained_chat*$points_chat+$points_gained_cedi*$points_cedi+$points_gained_posting*$points_posting+$points_gained_given+$points_gained_rating*$points_rating+$points_gained_voting*$points_voting+$points_gained_auto;

    
$TOTAL_POINTS_CACHE[$member]=$points;

    return 
$points;
}


I haven't tested it, and I hard-coded group ID #123.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Support me on Patreon
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: