Author Topic: [REQ}User promoted to usergroup after xx uploads? [SOLVED with details]  (Read 6741 times)

0 Members and 1 Guest are viewing this topic.

Offline TassieAnna

  • Pre-Newbie
  • Posts: 3
    • View Profile
I have seen that others mentioned they have done this, and am hoping there is an easy way to achieve it, already published somewhere here. Though my searches and browsing have not uncovered this.

What I would like to achieve is have a user promoted to a new group after uplaoding 5 images. This would then grant them extra permissions, etc.

I want to avoid having to insert database queries over and over again, so that once they are promoted, there is no need to check again.

Has anyone a simple modification that will achieve this? I am using version 1.7.4

Any help would be greatly appreciated.

thank you

edit:

I have been playing at trying to make the following code work, but keep getting an error regarding the last )

Code: [Select]
  $sql = "SELECT COUNT(image_id) AS totimg
         FROM ".IMAGES_TABLE."
         WHERE  user_id = $user_id";
  $result = $site_db->query($sql);
$row = $site_db->fetch_array($result);
$uploaded_images = $row['totimg'];
if ($uploaded_images ==5) {
 $sql = "INSERT INTO ".GROUP_MATCH_TABLE."
                (group_id, user_id, groupmatch_startdate, groupmatch_enddate)
                VALUES
                (3, $user_id, $current_time, 0)";
        $site_db->query($sql);
)

Also, I have been trying to insert this into member.php around the point after an image is uploaded.

I am also thinking that this does not first check to see if the user has already been entered into the group.

Currently returning to ripping my hair out, as this is the last thing I need to organise before letting my site go live.
« Last Edit: April 21, 2007, 05:08:28 AM by TassieAnna »

Offline TassieAnna

  • Pre-Newbie
  • Posts: 3
    • View Profile
Slightly disappointed that nobody attempted to assist with this, especially as it was not a difficult modification. Though it did prove tricky to get fully functional in the end.

The basic idea was that I wanted to disallow voting on images until the user had uploaded 5 of their own. Voting was restricted to a new usergroup that I created, and the details below show how to assign a user automatically to a usergroup.

This will automatically assign a user to a specified usergroup once they have uploaded a specified number of images to the gallery.

In member.php find:
Code: [Select]
  $sql = "INSERT INTO ".IMAGES_TEMP_TABLE."
                (cat_id, user_id, image_name, image_description, image_keywords, image_date, image_media_file, image_thumb_file, image_download_url".$additional_field_sql.")
                VALUES
                ($cat_id, ".$user_info['user_id'].", '$image_name', '$image_description', '$image_keywords', $current_time, '$new_name', '$new_thumb_name', '$image_download_url'".$additional_value_sql.")";
        $result = $site_db->query($sql);
      }
 
   
Add below:
Code: [Select]
//-------------------------------------------------------
//--- START assign user to group after upload x images --
//-------------------------------------------------------

if ($user_info['user_id'] != 0) {
$userv_id=$user_info['user_id'];
$sql = "SELECT group_id
       FROM ".GROUP_MATCH_TABLE."
         WHERE  user_id = $userv_id";
       $result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
  if ($num_rows < 1){
  $sql = "SELECT COUNT(image_id) AS totimg
         FROM ".IMAGES_TABLE."
         WHERE  user_id = $userv_id";
  $result = $site_db->query($sql);
$row = $site_db->fetch_array($result);
$uploaded_images = $row['totimg'];
if ($uploaded_images > 4) {
 $sql = "INSERT INTO ".GROUP_MATCH_TABLE."
                (group_id, user_id, groupmatch_startdate, groupmatch_enddate)
                VALUES
                ('3', '$userv_id', '$current_time', '0')";
        $site_db->query($sql);
       }
       }
      }
//-------------------------------------------------------
//--- END assign user to group after upload x images ----
//-------------------------------------------------------
Please note that you will need to change the values to suit your needs as shown below:

if ($uploaded_images > 4) assign here the number of images they must first upload to qualify for new group. This example requires the user to upload 5 images (a number greater than 4).

Just below that is:
Code: [Select]
VALUES
('3', '$userv_id', '$current_time', '0')";

The first number (3, in this case) is the number of the usergroup to which you wish the user assigned.


Offline milance

  • Newbie
  • *
  • Posts: 28
    • View Profile
Do this to fix that works with 1.7.11.
 thanks  :D

 

Post your comments here