Extend existing Custom Post Type
-
Hi,
Am looking at extending an existing Custom field (of another plugin) as a select tag for the charitable plugins.
I have close to 100 students who may be sponsored, Our idea is to allow the user to select the student prior to donating and this may be saved in the donations CPT.
I tried the following code
function ed_collect_student_name( $fields, Charitable_Donation_Form $form ) {
query_posts( array( ‘post_type’ => ‘student’,’posts_per_page’=>-1,$echo=”false” ));
while ( have_posts() ) : the_post();
$title_list[] = array(‘name’ => the_title(), ‘value’ => the_title());
endwhile;
$fields[‘student_name’] = array(
‘label’ => __( ‘student Name’, ‘your-namespace’ ),
‘type’ => ‘select’,
‘priority’ => 24,
‘value’ => $form->get_user_value( ‘donor_student_name’ ),
‘options’ => $title_list,
‘required’ => true,
‘data_type’ => ‘user’
);
return $fields;
}
add_filter( ‘charitable_donation_form_user_fields’, ‘ed_collect_student_name’, 10, 2 );function ed_donation_export_add_student_name_column( $columns ) {
$columns[‘student_name’] = __( ‘student Name’, ‘your-namespace’ );
return $columns;
}
add_filter( ‘charitable_export_donations_columns’, ‘ed_donation_export_add_student_name_column’ );function ed_donation_export_add_student_name_value( $value, $key, $data ) {
if ( ‘student_name’ != $key ) {
return $value;
}
return ed_donation_get_student_name( charitable_get_donation( $data[‘donation_id’] ) );
}
add_filter( ‘charitable_export_data_key_value’, ‘ed_donation_export_student_name_value’, 10, 3 );What I get is the entire post being displayed in a loop instead only the Post Title and the drop down box only has numbers.
Could you assist
Vijay
- The topic ‘Extend existing Custom Post Type’ is closed to new replies.