×
Please submit new Bug Reports on GitHub: github.com/Jensen-Technologies/component-creator-issues/issues
Accessing user data
Terry Nuttall
New Member
Posts: 1
4 năm 2 tuần trước #9805
bởi Terry Nuttall
Accessing user data was created by Terry Nuttall
Can you access any table using CC or can you only create a table ?
I want to create a component that gets the user name and user id but don't know how to tell CC to do this - the videos dont help!
I want to create a component that gets the user name and user id but don't know how to tell CC to do this - the videos dont help!
Vui lòng Đăng nhập hoặc Tạo tài khoản để tham gia cuộc hội thoại.
Carl Fuentes
Moderator
Posts: 28
4 năm 1 tuần trước #9810
bởi Carl Fuentes
Replied by Carl Fuentes on topic Accessing user data
If you create the component with table the same name and fields. you can access that table data.
Vui lòng Đăng nhập hoặc Tạo tài khoản để tham gia cuộc hội thoại.
Glenn Arkell
New Member
Posts: 7
3 năm 11 tháng trước #9812
bởi Glenn Arkell
Replied by Glenn Arkell on topic Accessing user data
Hi Terry,
I'm assuming from this question that you are not comfortable with editing (or do not wish to edit) the component once you have built it within Component Creator? If this is the case then I'll leave you with the previous response.
If you are willing to edit the component outside Component Creator, then getting user data is really quite simple using the standard Joomla! APIs.
As this post is a month old you may have already discovered this anyway but for those others that wish to do this then . . .
Firstly you will find that Component Creator uses these APIs through the generated code, and why wouldn't you. You can access the "current" user data by simply adding something like:
$user = Factory::getUser(); // this will return the complete user record as an object (correct for J3.9+)
Then you can pick out elements of the user object such as:
$user_id = $user->id;
Hope this helps in some small way. Cheers.
Glenn
I'm assuming from this question that you are not comfortable with editing (or do not wish to edit) the component once you have built it within Component Creator? If this is the case then I'll leave you with the previous response.
If you are willing to edit the component outside Component Creator, then getting user data is really quite simple using the standard Joomla! APIs.
As this post is a month old you may have already discovered this anyway but for those others that wish to do this then . . .
Firstly you will find that Component Creator uses these APIs through the generated code, and why wouldn't you. You can access the "current" user data by simply adding something like:
$user = Factory::getUser(); // this will return the complete user record as an object (correct for J3.9+)
Then you can pick out elements of the user object such as:
$user_id = $user->id;
Hope this helps in some small way. Cheers.
Glenn
Vui lòng Đăng nhập hoặc Tạo tài khoản để tham gia cuộc hội thoại.
Thời gian tải trang: 0.051 giây