我想在基于user_photo
的网站上添加UserCake PHP
(用户图片网址)字段,您知道这个脚本吗?
我知道如何将该字段添加到注册页面,将该URL添加到数据库中,但我不知道如何将其用作显示名称:当我放入&loggedInUser->displayname
时,它返回,例如,GrupoActemp。
我想提交它返回的&loggedInUser->picture
,&loggedInUser->image
或&loggedInUser->photo
,例如http://www.imageserver.com/directory/image.png
。
信息:db表名为user_photo
答案 0 :(得分:2)
猜猜是什么,我刚刚遇到了这个问题并且刚刚解决了这个问题。我不得不追溯所有对象,然后得到了这个东西。 将字段添加到register.ph和newuser类后,
多数民众赞成。使用此代码检查您是否有您想要的字段:
<pre>
<?php print_r(get_object_vars($loggedInUser)); ?>
</pre>
例如,我想添加dob(出生日期)字段,在将值添加到register,新用户类和func.php文件,登录文件之后,我的文件看起来像这样:
的login.php
//Construct a new logged in user object
//Transfer some db data to the session object
$loggedInUser = new loggedInUser();
$loggedInUser->email = $userdetails["email"];
$loggedInUser->user_id = $userdetails["id"];
$loggedInUser->hash_pw = $userdetails["password"];
$loggedInUser->title = $userdetails["title"];
$loggedInUser->displayname = $userdetails["display_name"];
$loggedInUser->username = $userdetails["user_name"];
$loggedInUser->dob = $userdetails["dob"];
funcs.php
//Retrieve complete user information by username, token or ID
function fetchUserDetails($username=NULL,$token=NULL, $id=NULL)
{
if($username!=NULL) {
$column = "user_name";
$data = $username;
}
elseif($token!=NULL) {
$column = "activation_token";
$data = $token;
}
elseif($id!=NULL) {
$column = "id";
$data = $id;
}
global $mysqli,$db_table_prefix;
$stmt = $mysqli->prepare("SELECT
id,
user_name,
display_name,
password,
email,
activation_token,
last_activation_request,
lost_password_request,
active,
title,
sign_up_stamp,
last_sign_in_stamp,
dob
FROM ".$db_table_prefix."users
WHERE
$column = ?
LIMIT 1");
$stmt->bind_param("s", $data);
$stmt->execute();
$stmt->bind_result($id, $user, $display, $password, $email, $token, $activationRequest, $passwordRequest, $active, $title, $signUp, $signIn,$dob);
while ($stmt->fetch()){
$row = array('id' => $id, 'user_name' => $user, 'display_name' => $display, 'password' => $password, 'email' => $email, 'activation_token' => $token, 'last_activation_request' => $activationRequest, 'lost_password_request' => $passwordRequest, 'active' => $active, 'title' => $title, 'sign_up_stamp' => $signUp, 'last_sign_in_stamp' => $signIn,'dob'=>$dob);
}
$stmt->close();
return ($row);
}
希望这有帮助。