Calling a custom profile field in SQL report

Re: Calling a custom profile field in SQL report

by José Augusto Moraes -
Number of replies: 3

Hi John;

I use this simple code:

global $USER;
$string = $USER->profile['fieldname'];

Just change the 'fieldname' to the custom field you want to display.

Hope that helps!

In reply to José Augusto Moraes

Re: Calling a custom profile field in SQL report

by Federica Marra -

Dear all, I'm trying to run this sql in Moodle 2.8.5 but it gives me an error message back!

Could someone help me in writing one sql to display a custom user profile field called "Targetgroup" in the shortname?

Thanks! 

In reply to Federica Marra

Re: Calling a custom profile field in SQL report

by Al Brocklehurst -

I got this working for Moodle 2.8+

Federica - if you are still having problems paste your sql and we'll look at it.

In reply to José Augusto Moraes

Re: Calling a custom profile field in SQL report

by Matt Polaniecki -

Where would this go? At the top? I'm sorry I'm new to this.