News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Require code that refers to time registered

Started by wtfwtf, January 29, 2019, 05:59:57 PM

Previous topic - Next topic

wtfwtf

hello
i have been struggling with a variable unable to find it
it is the one that determines the date registered
i found: $user_profile[$memID]['date_registered'];
but for some reason i can't echo it nor get it's value
is there another way to access this value, if not, what is the proper way to get this variable

Kindred

Where, and in what way are you trying to get and use this info?
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

wtfwtf

Quote from: Kindred on January 29, 2019, 11:12:08 PM
Where, and in what way are you trying to get and use this info?
hi
i just need the member registration date for a small modification i am doing on my test forum
i can't seam to find the variable that gives the value
the above variable "$user_profile[$memID]['date_registered'];"
was found in profile-view.php
but i can't get it to work or even echo on another page

Arantor

That's because the profile of a single user is loaded in full in the profile but for performance it isn't loaded elsewhere.

Are you interested in the current user or someone else? If the current user, take a look in $user_info.

wtfwtf

Quote from: Arantor on January 30, 2019, 07:42:36 AM
That's because the profile of a single user is loaded in full in the profile but for performance it isn't loaded elsewhere.

Are you interested in the current user or someone else? If the current user, take a look in $user_info.

yes current user,
but user info does not have the user registration time

Arantor


wtfwtf


Arantor

I don't remember, but I assume if you know how to write code that can use it, you can also var_dump it. It's not like I'm in front of my home PC where I have the source available to me.

wtfwtf

Quote from: Arantor on January 30, 2019, 02:18:03 PM
I don't remember, but I assume if you know how to write code that can use it, you can also var_dump it. It's not like I'm in front of my home PC where I have the source available to me.

well that's the problem, don't remember much coding
everything takes forever to come together,
thus any help would be appreciated

Arantor

So, essentially once we give you the relevant bit, we then need to explain how to use it?

How about explaining what you're trying to do this time (first)?

wtfwtf

Quote from: Arantor on January 30, 2019, 03:24:57 PM
So, essentially once we give you the relevant bit, we then need to explain how to use it?

How about explaining what you're trying to do this time (first)?

no need to explain how to use it, i am a programmer, a bad one but still can manage to handle this
the only problem is i need to get the variable, which should not be so complicated in theory , except for this one it seams it is.
thus the request can't be simpler in theory

Arantor


wtfwtf

Quote from: Arantor on January 30, 2019, 04:46:46 PM
Fine.

$user_settings['date_registered'].

i actually tried this one,
it's like the $user_profile[$memID]['date_registered'];
doesn't work on other pages
actually all the $user_settings['x'] do not work on other pages

Arantor

Then you, or some mod you have installed, has broken your SMF installation.

$user_settings is populated during the startup of SMF (during loadUserSettings) as a global variable, before transferring a subset of the values in it to $user_info. It's literally created as one of the first things that is set up during SMF, and it starts out as the entire contents of the row from the smf_members table for the current user - but of course will be less than complete for guest users.

$user_profile is made a different way but ultimately the same general concept on the back of a call to loadMemberData, but is not automatically loaded for any given user (not even the current user), its predominant use is on the profile page where it is used to populate $user_profile as an array with the index of the array being the user id (so if you call it for users 1, 2 and 3, it will create $user_profile[1], $user_profile[2] and $user_profile[3])

I have no idea how the hell you broke SMF.


EDIT: This of course assumes that you understand what a global variable is and included it into scope. If not, try global $user_settings where you're trying to use it.

wtfwtf

Quote from: Arantor on January 30, 2019, 04:54:36 PM
Then you, or some mod you have installed, has broken your SMF installation.

$user_settings is populated during the startup of SMF (during loadUserSettings) as a global variable, before transferring a subset of the values in it to $user_info. It's literally created as one of the first things that is set up during SMF, and it starts out as the entire contents of the row from the smf_members table for the current user - but of course will be less than complete for guest users.

$user_profile is made a different way but ultimately the same general concept on the back of a call to loadMemberData, but is not automatically loaded for any given user (not even the current user), its predominant use is on the profile page where it is used to populate $user_profile as an array with the index of the array being the user id (so if you call it for users 1, 2 and 3, it will create $user_profile[1], $user_profile[2] and $user_profile[3])

I have no idea how the hell you broke SMF.

ok will try on a fresh installation

Arantor

See also my edit, I assumed you knew what variable scope was, being a programmer and all.

wtfwtf

Quote from: Arantor on January 30, 2019, 05:01:09 PM
See also my edit, I assumed you knew what variable scope was, being a programmer and all.
ok will try
i'm a bad programmer that haven't really done any programming in a long while , thus this makes me like an amateur

wtfwtf

ok did the trick the variable scope was the issue
thank you !!

Advertisement: