Opened 17 months ago
Closed 16 months ago
#19809 closed defect (bug) (invalid)
can't pass an array(class, method) as a callback in add_settings_field()
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | General | Version: | 3.3.1 |
| Severity: | normal | Keywords: | close |
| Cc: |
Description
I want to pass an array(class, method) as a callback for a settings field:
add_settings_field($field, $label, array(&$this, $method) , $slug, $section, $field);
But 'do_settings_sections' don't do a check like 'add_filter()' and it's used as string with 'call_user_func' in wp-admin/includes/template.php:1103
Change History (5)
call_user_func can handle callbacks including array(class, method). There's no requirement that the callback is a string. Your issue is likely that whatever you are passing does not calculate to be a valid callback.
You are right, it's handle it and it work for me, but I get the php error...
comment:4
solarissmoke — 16 months ago
- Keywords close added
comment:5
SergeyBiryukov — 16 months ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
Feel free to reopen with more exact steps to reproduce if there's still a problem.

The PHP error is:
Warning: call_user_func() [function.call-user-func]: First argument is expected to be a valid callback in /wp-admin/includes/template.php on line 1102