I'm trying out the "PHP Login & User Management" plugin, which allows custom fields in a user's profile.
However, for some reason, this is implemented on a seperate table, so in order to pull up "Phone Number" for example, I have to get my user_id from login_users, go into the login_profile_fields table, find the correct row, pull id and label, and find the row in login_profiles where id=pfield_id and user_id = user_id.
I'm trying to write an SQL query to display the following information in the end:
name | email | Phone Number | Zip Code | Department | Skills | Manager Email | Company Code | Status
WHERE a chosen value in login_profiles is X (example: "List the above info for all users who have a Status code of 1")
Is there a way for me to do this?
Alternatively, is there a way I can automatically populate the login_profiles table with values from login_profiles, like so?
login_profiles
p_id | pfield_id | user_id | profile_value | Phone Number | Zip Code | ...
1 | 1 | 1 | 18005551212 | {Select profile_value from login_profiles where user_id=user_id and pfield_id=1} | {Select profile_value from login_profiles where user_id=user_id and pfield_id=2} | ...
Here are my current tables:
login_profile_fields
id | section | type | label |
1 | User Info | text_input | Phone Number |
2 | User Info | text_input | Zip Code |
3 | Work Info | text_input | Department |
4 | Work Info | text_input | Skills |
5 | Work Info | text_input | Manager Email |
6 | Work Info | text_input | Company Code |
7 | Work Info | checkbox | Status |
login_profiles
p_id | pfield_id | user_id | profile_value |
1 | 1 | 1 | 18005551212 |
2 | 2 | 1 | 90210 |
3 | 3 | 1 | Marketing |
4 | 4 | 1 | Segmentations and surveys |
5 | 5 | 1 | [email protected] |
6 | 6 | 1 | COMP1 |
7 | 7 | 1 | 1 |
1 | 1 | 2 | 18007771234 |
2 | 2 | 2 | 90218 |
3 | 3 | 2 | CEO |
4 | 4 | 2 | Business strategy |
5 | 5 | 2 | [email protected] |
6 | 6 | 2 | COMP1 |
7 | 7 | 2 | 1 |
login_users
user_id| name | email |
1 | Michael Bluth | [email protected] |
2 | George Bluth | [email protected] |
I'm not a MYSQL person by training, but I'm learning all I can, so any advice is very much appreciated!