0

i am trying to find out how to search the cms database for a specific users username based on their user id and not based on logged in.

Any documentation links or advice would be great, have tried using various ways but ultimately i think query is the way but i am unsure of how to find a specific users username.

i have tried this but i need to do this using the ee() classes in some way as i cannoe seem to define a php variable with the following :

{exp:query sql="SELECT screen_name FROM exp_members WHERE member_id = '1' "}
        {screen_name}
{/exp:query}

please advise and many thanks!

  • Can you expand your question as it's not clear what you're asking, queries are the right approach dependent on your needs. – stuartmcd69 May 10 '15 at 1:49
1

It would seem you want to do this with a php approach over using the exp:query because of some php variable you want to use with it? If so, check out the Database Class Docs over in the EE documentation.

Since we know that only one member will have an id of one, we can use a simple query like so:

$results = ee()->db->order_by('member_id')
 ->limit(1)
 ->get('exp_members');
 ->where(array('exp_members.memberr_id'=> '1'));

$first_member = $results->row('screen_name');
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.