Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
441 views
in Q2A Core by
I got really used to function qa_db_usermeta_get() and thought the same would exist for the userprofile fields. However, it does not yet.

@Scott: Please consider adding:

        // CUSTOM function added
        function qa_db_user_profile_get($userid, $field)
        {
            return qa_db_read_one_value(
                    qa_db_query_sub(
                        'SELECT content FROM ^userprofile
                            WHERE `userid` = #
                            AND `title` = #',
                        $userid, $field),
                    true);
        }

Thanks.
Q2A version: 1.7.4

1 Answer

+1 vote
by

I think you are looking for qa_db_user_profile_selectspec from db/selects.php. You should pass the result into qa_db_single_select to get the output:

$profile = qa_db_single_select(qa_db_user_profile_selectspec($useridhandle, $isuserid));

$useridhandle is either the numeric user ID, or the username (handle). $isuserid should be true if you passed in a user ID or false if you passed in the handle. In other words, either of these:

$profile = qa_db_single_select(qa_db_user_profile_selectspec(1234, true));
$profile = qa_db_single_select(qa_db_user_profile_selectspec('q2apro', false));

Hope that helps!

by
As far as I see this gives me all the data. It would be sufficient in my case to get only one profile field.
...