Advertisement:

Author Topic: Require code that refers to time registered  (Read 928 times)

Offline wtfwtf

  • Semi-Newbie
  • *
  • Posts: 94
Require code that refers to time registered
« on: January 29, 2019, 05:59:57 PM »
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

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,557
  • Gender: Male
    • Kindred-999 on GitHub
Re: Require code that refers to time registered
« Reply #1 on: January 29, 2019, 11:12:08 PM »
Where, and in what way are you trying to get and use this info?
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline wtfwtf

  • Semi-Newbie
  • *
  • Posts: 94
Re: Require code that refers to time registered
« Reply #2 on: January 30, 2019, 05:04:15 AM »
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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,813
    • StoryBB/StoryBB on GitHub
Re: Require code that refers to time registered
« Reply #3 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.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline wtfwtf

  • Semi-Newbie
  • *
  • Posts: 94
Re: Require code that refers to time registered
« Reply #4 on: January 30, 2019, 08:00:49 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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,813
    • StoryBB/StoryBB on GitHub
Re: Require code that refers to time registered
« Reply #5 on: January 30, 2019, 08:06:38 AM »
Then try $user_settings.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline wtfwtf

  • Semi-Newbie
  • *
  • Posts: 94
Re: Require code that refers to time registered
« Reply #6 on: January 30, 2019, 02:06:50 PM »
Then try $user_settings.
what would be the exact syntax ?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,813
    • StoryBB/StoryBB on GitHub
Re: Require code that refers to time registered
« Reply #7 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.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline wtfwtf

  • Semi-Newbie
  • *
  • Posts: 94
Re: Require code that refers to time registered
« Reply #8 on: January 30, 2019, 03:04:41 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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,813
    • StoryBB/StoryBB on GitHub
Re: Require code that refers to time registered
« Reply #9 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)?
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline wtfwtf

  • Semi-Newbie
  • *
  • Posts: 94
Re: Require code that refers to time registered
« Reply #10 on: January 30, 2019, 04:28:04 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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,813
    • StoryBB/StoryBB on GitHub
Re: Require code that refers to time registered
« Reply #11 on: January 30, 2019, 04:46:46 PM »
Fine.

$user_settings['date_registered'].
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline wtfwtf

  • Semi-Newbie
  • *
  • Posts: 94
Re: Require code that refers to time registered
« Reply #12 on: January 30, 2019, 04:50:03 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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,813
    • StoryBB/StoryBB on GitHub
Re: Require code that refers to time registered
« Reply #13 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.


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.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline wtfwtf

  • Semi-Newbie
  • *
  • Posts: 94
Re: Require code that refers to time registered
« Reply #14 on: January 30, 2019, 05:00:24 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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,813
    • StoryBB/StoryBB on GitHub
Re: Require code that refers to time registered
« Reply #15 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.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline wtfwtf

  • Semi-Newbie
  • *
  • Posts: 94
Re: Require code that refers to time registered
« Reply #16 on: January 30, 2019, 05:27:53 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

Offline wtfwtf

  • Semi-Newbie
  • *
  • Posts: 94
Re: Require code that refers to time registered
« Reply #17 on: January 30, 2019, 05:42:13 PM »
ok did the trick the variable scope was the issue
thank you !!