I'm trying to login users by detecting it's facebook user id.
"profile_fbuid" is a (hidden) profile field that I created to login users with the corresponding facebook user id.
When a user tries to login with Facebook I detect his/her facebook user id, but when I try to match with corresponding Drupal user this line doesn't work:
$user_exists = user_load(array('profile_fbuid'=>$fbuserid));
I get this error: user warning: Unknown column 'profile_fbuid'
I know what the error means, but I don't know how can I search a user using a user profile field.
Thanks for your help!
You created a custom field that is attached to the user profile called profile_fbuid. What you want to do in the database is look for this table:
field_data_field_profile_fbuid.
The relevant columns are entity_id, which will be the (Drupal) user id, and field_profile_fbuid_value, which will contain the value (the Facebook UID).
There is no field in the users table called profile_fbuid, so I assume you generated this field by using the user profile module.
I think it's better to create a query which gets the uid of this column and then passes it to the user_load() function.
$query = db_query("select `uid` from {table_name} where `profile_fbuid` = %d ",$fbuserid );
while($result = db_fetch_object($query)){
$uid = $result->uid ;
$user_exists = user_load(array('uid'=>$uid));
}
Related
I am new to Drupal. How do I get all user data in a single query or function, including extra fields like middle name, phone # from:
Configuration » People » Account settings
I want all the records of all the users, including the extra fields listed above. How can I achieve this?
If the fields are attached to the user : user_load();
Something like :
$user = user_load(1); // 1 = uid of admin user
drupal_set_message($user->field_middle_name); // print a message with your user custom field named middle_name.
If you got many users to load, use user_load_multiple, the perfs will be better.
I have 2 roles in my drupal site. One is admin. The uid is 1. If I visit the profile of another user, say a user with uid 2, is it possible to get that value. I did not want to retrieve it from the url(user/2). Is there any other way to get a user information like uid, role etc while visiting profile of another user. I think $user can be used to get the details of current user only.
To get the details from user id when you are in the profile page of that user use the $account variable. More details in the user-profile.tpl.php template inside ROOT/modules/user.
Example, get user id: $account->uid;
I'm working on using the membership functionality of the ASP .Net sites. There are multiple ways to create users and one way is to create users and add a user profile to the system. The other is to use an enhanced wizard then add the user and then their profile information. Well, if you go route 1, then the user does not get a record inserted into the user profile table and then when the user goes to update their profile, then on the page load I would like the page to look for their record. If one does not exist, insert a blank one. Does anyone have a sample script to look up a user's profile based on their unique id in SQL CE? If the record does not exist (record count = 0) then insert a new blank record.
When I load up a grid view (which is supposed to display data of that user). However, when I log in as a user and view the grid view it displays both the current user's data and others' data. I want it to only display the current logged in user's data.
How would I use userid = convert.toint32(session["userId"].tostring()) to check my current logged in user's username and display only their data from the database's table?
Just make your query to get the data something like
"Select * from SomeTable Where UserId = #userId"
And then set the parameter to userid
Same way as you'd do a query based on user input.
i am creating site like say LinkedIn/spoke
like when i login ,i give my login id and password so database
checks it and allow me to access my profile
i need to know that in stackoverflow when we click to users
button all the users in stackoverflow are shown
but when i click to specific user
how does the database known that this specific user is clicked
and show's his/her profile data ?
should i create new page for viewing others user profile ?
and if i do so what will be the query for that
If you have 2 seperate queries then it makes easier (I'm not saying this is the best solution). So, you could have a 'select all users' query which could be something as simple as :
SELECT *
FROM MyUsers
This will return all of your users to your website, so you can view them. Then, when you select a user from your website, you call a different query, say 'select a single user', and pass a parameter from your website. The query could look something like :
SELECT *
FROM MyUsers
WHERE UserID = #UserID
This could be done in one stored procedure and test if your #UserID is NULL then run the required SELECT statement.