Closed nielslange closed 3 years ago
This problem was caused due to the missing $groups
parameter in the functions call. The correct function looks like this and adds the phone number to the contact info section as expected:
add_filter( 'coauthors_guest_author_fields', 'edit_coauthors_guest_author_fields', 10, 2 );
function edit_coauthors_guest_author_fields( $fields_to_return, $groups ) {
if ( in_array( 'all', $groups ) || in_array( 'contact-info', $groups ) ) {
$fields_to_return[] = array(
'key' => 'name',
'label' => 'Phone number',
'group' => 'contact-info',
);
}
return $fields_to_return;
}
Reported in https://wordpress.org/support/topic/how-to-utilize-the-coauthors_guest_author_fields-filter/
Steps to reproduce
Add the following code to your site:
/wp-admin/post-new.php?post_type=guest-author
Phone number
appears in all sectionsCurrent behaviour
The field
Phone number
appears in all sections,Name
,Contact Info
andAbout the guest author
.Expected behaviour
The field
Phone number
appears only in the sectionContact Info
.Screenshots
![current](https://user-images.githubusercontent.com/3323310/112571384-7baa8a00-8e1a-11eb-835a-fbeafea7d721.png)
![expected](https://user-images.githubusercontent.com/3323310/112571387-7d744d80-8e1a-11eb-8049-3ca51820321d.png)