Admin change User Picture

18 years 2 months ago #5112 by deimann
Admin change User Picture was created by deimann
How can i, as an admin, change the User Photo?

Please Log in to join the conversation.

18 years 2 months ago #5119 by rick
Replied by rick on topic Re:Admin change User Picture
Without using mysql you can't. If you are really intent on this then you would have to go into mysql find the user id then find the photo associated to that id and replace it with the new photo.

Rick

Running:
Joomla! 1.0.7 Stable
Community Builder 1.0 rc2
SMF 1.1 RC2

Please Log in to join the conversation.

18 years 2 months ago #5121 by deimann
Replied by deimann on topic Re:Admin change User Picture
Well, my problem is that there are no pictures yet, and i want to attach them.
I already tried it in sql, but it does not work. I updated the user entry in jos_comprofiler. But it seems that it is not enough just tu put a Filename (which exists in the right directory) in the field avatar.

Please Log in to join the conversation.

18 years 2 months ago #5142 by Overhaul
Replied by Overhaul on topic Re:Admin change User Picture
I went thru this a couple months back. Here is what I found at MamboJoe.com :

Right now the only way for an admin to add photos is to log into your cpanel and access your myphpadmin. Of course back up your database first, before you start playing. Just in case.

Find the mos_comprofiler table, and click the browse tab. You will then see all your users. You will then access the user you want to add a photo to by clicking on the pencil. Make sure nothing is checked "null". Put the name of the photo in the avatar field, and the following approved and confirmed fields should have a "1" in them. Scroll to the bottom of the page and click "Go".

You will need to upload the images by ftp to the folder that contains the avatars on your server. I create both a thumbnail and the regular photo. 60x80 for the thumb, and 200x267 for the standard photo. If the image you have is named "bill.jpg", call the thumb "tnbill.jpg".

It is a pain in the butt, but it works. I had to go through this for a company employee site.

If anyone has an easier way to do it, I would love to hear it. It would make my life easier.


www.mambojoe.com/index.php?option=com_simpleboard&Itemid=25&func=view&catid=6&id=8181#8181

I hope this helps. I'm not sure if it is the same with RC2. I did this with while using the RC1 release.

Please Log in to join the conversation.

17 years 8 months ago #18534 by Jeque
Replied by Jeque on topic Re:Admin change User Picture
There is my php-script to add/change user photo.
Some of variables must be edited.

[code:1]
<?php
$hostname = "localhost";
$database = "intranet";
$username = "root";
$password = "";
$link = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
session_start();
mysql_select_db($database, $link);
$query = "SELECT * FROM jos_users ORDER BY username ASC";
$result = mysql_query($query, $link) or die(mysql_error());
$users = mysql_fetch_assoc($result);
?>

<html>
<head>
<title>Upload/Change user photo</title>
</head>
<body>
<h2>Upload/Change user photo:</h2>
<form action="<?php echo $_SERVER;?>" method="post" enctype="multipart/form-data">
<p>Username: <select name="user" size=1>
<?php
while ($row = mysql_fetch_assoc($result)) {
echo "<option value=".$row["username"].">".$row["username"]."</option>";
}
mysql_free_result($result);
?>
</select><br/>
<p>Upload photo:<br/>
<input type="file" name="pictures[]" /><br/>
<input type="submit" name="upload" value="Upload" /><br/>
</p>
</form>
<?php

if (!isset($_POST["upload"])) {
exit;
}
$filename = "_".$_FILES["pictures"]["name"][0];
$uploaddir = '/usr/local/www/pub/intranet/images/comprofiler/';
$uploadfile = $uploaddir.$filename;
move_uploaded_file($_FILES["pictures"]["tmp_name"][0], $uploadfile) or die("Upload failed"«»);
$destWidth = 70; //preview width
$destHeight = 87; //preview height
$JPEGquality = 95;
$src_file = $uploadfile;
$dst_file = $uploaddir."tn".$filename;
$imginfo = getimagesize($src_file);
$src_img = imagecreatefromjpeg($src_file);
$dst_img = imagecreatetruecolor($destWidth, $destHeight);
imagecopyresized ($dst_img, $src_img, 0, 0, 0, 0, $destWidth, $destHeight, $imginfo[0], $imginfo[1]);
imagejpeg ($dst_img, $dst_file, $JPEGquality);
imagedestroy($src_img);
imagedestroy($dst_img);
if ($_FILES["pictures"]["name"][0] != ""«») {
$user=$_POST;
$query = "SELECT * FROM jos_users WHERE username = '".$user."'";
$result = mysql_query($query, $link) or die(mysql_error());
$id = mysql_fetch_assoc($result);
$userid = $id["id"];
mysql_free_result($result);
$query = "UPDATE jos_comprofiler SET avatar = '".$_FILES["pictures"]["name"][0]."' WHERE user_id = 66";
$query = "UPDATE `jos_comprofiler` SET `avatar` = '".$filename."' WHERE `user_id` = ".$userid;
echo $query;
$result = mysql_query($query, $link) or die(mysql_error());
echo "<br/>File ".$_FILES["pictures"]["name"][0]." has been uploaded as a photo of the user ".$user;
}
?>
</body>
</html>

[/code:1]

Please Log in to join the conversation.

17 years 7 months ago #20917 by Joey2804
Replied by Joey2804 on topic Re:Admin change User Picture
To where am I adding this script, and if it's a new page, which it looks like it is, what is the filename for the file?

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.456 seconds

Facebook Twitter LinkedIn