1

I've written this piece of code, which outputs the profile_display_fields for the $USER:

$appearance = profile_display_fields($USER->id);
        if (empty($appearance)) {
            //Do nothing
        } else {
            foreach ($appearance as $c) {
            $custom .= '<a href=\''.$CFG->wwwroot.'/course/view.php?id='.$c->id.'\'>'.$c->fullname.'</a>';
            }
        }

Here is the function I'm using:

function profile_display_fields($userid) {
    global $CFG, $USER;

    if ($categories = get_records_select('user_info_category', '', 'sortorder ASC')) {
        foreach ($categories as $category) {
            if ($fields = get_records_select('user_info_field', "categoryid=$category->id", 'sortorder ASC')) {
                foreach ($fields as $field) {
                    require_once($CFG->dirroot.'/user/profile/field/'.$field->datatype.'/field.class.php');
                    $newfield = 'profile_field_'.$field->datatype;
                    $formfield = new $newfield($field->id, $userid);
                    if ($formfield->is_visible() and !$formfield->is_empty()) {
                        print_row(s($formfield->field->name.':'), $formfield->display_data());
                    }
                }
            }
        }
    }
}

What I'm looking to do is try some var_dumps to output the correct data.

However can anyone help me identify the variables?

3
  • what do you want to var_dump? which variable? Commented Feb 21, 2010 at 12:16
  • I know var_dump($something); but which are the variables in the PHP above? Commented Feb 21, 2010 at 12:18
  • As you have written the code, you should know the $something s are variables... Commented Feb 21, 2010 at 12:19

1 Answer 1

1

In your function you are not returning any value but above that in your code, you have assigned a variable to this function:

$appearance = profile_display_fields($USER->id);

You need to return some variable/data from the function and that is the one to be var dumped.

I suppose you are using the print_row to print the data, not returning the response to be used out of the function.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.