 X-perienced ~PHP Nuke User~ Posts: 110
Next Group: 40 posts
Anna wrote:Finally have this one nailed down tight and working
For anyone else who may like to use it (though this probably will not work on nuked versions), the solution is ...
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: |
$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: |
//-------------------------------------------------------
//--- 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: |
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.
As an example of how this can be used... I am setting up an image rating site where the requirement is that a person upload 5 images of their own before they are allowed to rate the images uploaded by others. This hack will automatically grant them the permission to vote (only available to a certain usergroup) once they upload their 5th image.
Thanks Mark for the early help.
Posted: Fri Apr 20, 2007 10:01 pm
 Site Admin ~PHP Nuke User~ Posts: 3324
StaffNext Group: 1676 posts
admin(Mark) wrote:It looks good Anna and thanks for posting the codes for other members
One thing I should mention is that you should always place your variables in single quote to prevent against sql injections.
Code: |
| user_id = $userv_id |
should be
Code: |
| user_id = '$userv_id' |
Also you can make sure the user id is a number by using intval
Code: |
$userv_id= intval($user_info['user_id']);
|
Posted: Sat Apr 21, 2007 3:06 pm
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
 |