Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#19809 closed defect (bug) (invalid)

can't pass an array(class, method) as a callback in add_settings_field()

Reported by: mati1000's profile mati1000 Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.3.1
Component: General Keywords: close
Focuses: Cc:


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)

#1 @mati1000
12 years ago

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

#2 @nacin
12 years ago

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.

#3 @mati1000
12 years ago

You are right, it's handle it and it work for me, but I get the php error...

#4 @solarissmoke
12 years ago

  • Keywords close added

#5 @SergeyBiryukov
12 years 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.

Note: See TracTickets for help on using tickets.