Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
703 views
in Q2A Core by
I'd like to get the website field of the currently logged in user. What's the best way to pull that and other profile information?
Q2A version: 1.4.3

1 Answer

+3 votes
by
selected by
 
Best answer

Here's the function in the badges plugin that is adapted from the core; it checks whether all fields are filled out, but of course you can do other things with the info:

        function check_user_fields($userid,$params) {
            list($useraccount, $userprofile, $userfields)=qa_db_select_with_pending(
                qa_db_user_account_selectspec($userid, true),
                qa_db_user_profile_selectspec($userid, true),
                qa_db_userfields_selectspec()
            );
                
            // avatar badge
            
            if (qa_opt('avatar_allow_upload') && isset($useraccount['avatarblobid'])) {
                $badges = array('avatar');
                qa_badge_award_check($badges, false, $userid);                
            }
            
            // profile completion
            
            $missing = false;
            
            foreach ($userfields as $userfield) {
                if(!$userprofile[$userfield['title']]) {
                    $missing = true;
                    break;
                }
            }
            
            if(!$missing) {
                $badges = array('profiler');
                qa_badge_award_check($badges, false, $userid);            
            }
            
        }

...