diff --git a/plugins/osi-features/acf-fields/group_672accc71e0c4.json b/plugins/osi-features/acf-fields/group_672accc71e0c4.json new file mode 100644 index 0000000..2ffed88 --- /dev/null +++ b/plugins/osi-features/acf-fields/group_672accc71e0c4.json @@ -0,0 +1,134 @@ +{ + "key": "group_672accc71e0c4", + "title": "Supporter fields", + "fields": [ + { + "key": "field_672accc74e66e", + "label": "Name", + "name": "name", + "aria-label": "", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "relevanssi_exclude": 0, + "default_value": "", + "maxlength": "", + "allow_in_bindings": 0, + "placeholder": "", + "prepend": "", + "append": "" + }, + { + "key": "field_672accd44e66f", + "label": "Organization", + "name": "organization", + "aria-label": "", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "relevanssi_exclude": 0, + "default_value": "", + "maxlength": "", + "allow_in_bindings": 0, + "placeholder": "", + "prepend": "", + "append": "" + }, + { + "key": "field_672ad07b77def", + "label": "Link", + "name": "link", + "aria-label": "", + "type": "url", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "relevanssi_exclude": 0, + "default_value": "", + "allow_in_bindings": 0, + "placeholder": "" + }, + { + "key": "field_672accda4e670", + "label": "Quote", + "name": "quote", + "aria-label": "", + "type": "textarea", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "relevanssi_exclude": 0, + "default_value": "", + "maxlength": "", + "allow_in_bindings": 0, + "rows": "", + "placeholder": "", + "new_lines": "" + }, + { + "key": "field_672ade5b950a0", + "label": "Order", + "name": "order", + "aria-label": "", + "type": "number", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "relevanssi_exclude": 0, + "default_value": "", + "min": "", + "max": "", + "allow_in_bindings": 0, + "placeholder": "", + "step": "", + "prepend": "", + "append": "" + } + ], + "location": [ + [ + { + "param": "post_type", + "operator": "==", + "value": "supporter" + } + ] + ], + "menu_order": 0, + "position": "normal", + "style": "default", + "label_placement": "top", + "instruction_placement": "label", + "hide_on_screen": "", + "active": true, + "description": "", + "show_in_rest": 0, + "modified": 1733133647 +} diff --git a/plugins/osi-features/acf-fields/post_type_672acc9b32c0c.json b/plugins/osi-features/acf-fields/post_type_672acc9b32c0c.json new file mode 100644 index 0000000..c1ce8c6 --- /dev/null +++ b/plugins/osi-features/acf-fields/post_type_672acc9b32c0c.json @@ -0,0 +1,89 @@ +{ + "key": "post_type_672acc9b32c0c", + "title": "Supporters", + "menu_order": 0, + "active": true, + "post_type": "supporter", + "advanced_configuration": true, + "import_source": "", + "import_date": "", + "labels": { + "name": "Supporters", + "singular_name": "Supporter", + "menu_name": "Supporters", + "all_items": "All Supporters", + "edit_item": "Edit Supporter", + "view_item": "View Supporter", + "view_items": "View Supporters", + "add_new_item": "Add New Supporter", + "add_new": "Add New Supporter", + "new_item": "New Supporter", + "parent_item_colon": "Parent Supporter:", + "search_items": "Search Supporters", + "not_found": "No supporters found", + "not_found_in_trash": "No supporters found in Trash", + "archives": "Supporter Archives", + "attributes": "Supporter Attributes", + "featured_image": "", + "set_featured_image": "", + "remove_featured_image": "", + "use_featured_image": "", + "insert_into_item": "Insert into supporter", + "uploaded_to_this_item": "Uploaded to this supporter", + "filter_items_list": "Filter supporters list", + "filter_by_date": "Filter supporters by date", + "items_list_navigation": "Supporters list navigation", + "items_list": "Supporters list", + "item_published": "Supporter published.", + "item_published_privately": "Supporter published privately.", + "item_reverted_to_draft": "Supporter reverted to draft.", + "item_scheduled": "Supporter scheduled.", + "item_updated": "Supporter updated.", + "item_link": "Supporter Link", + "item_link_description": "A link to a supporter." + }, + "description": "", + "public": true, + "hierarchical": false, + "exclude_from_search": false, + "publicly_queryable": true, + "show_ui": true, + "show_in_menu": true, + "admin_menu_parent": "", + "show_in_admin_bar": true, + "show_in_nav_menus": true, + "show_in_rest": true, + "rest_base": "", + "rest_namespace": "wp\/v2", + "rest_controller_class": "WP_REST_Posts_Controller", + "menu_position": "", + "menu_icon": { + "type": "dashicons", + "value": "dashicons-admin-post" + }, + "rename_capabilities": false, + "singular_capability_name": "post", + "plural_capability_name": "posts", + "supports": [ + "title", + "thumbnail", + "custom-fields" + ], + "taxonomies": "", + "has_archive": false, + "has_archive_slug": "", + "rewrite": { + "permalink_rewrite": "custom_permalink", + "slug": "supporter", + "with_front": "0", + "feeds": "0", + "pages": "1" + }, + "query_var": "post_type_key", + "query_var_name": "", + "can_export": true, + "delete_with_user": false, + "register_meta_box_cb": "", + "enter_title_here": "", + "modified": 1734435097 +} \ No newline at end of file diff --git a/themes/osi/functions.php b/themes/osi/functions.php index 9e9b947..dc965af 100755 --- a/themes/osi/functions.php +++ b/themes/osi/functions.php @@ -425,3 +425,39 @@ function osi_wpdc_comment_body( string $comment_body ) { return $trimmed_comment_body; } add_filter( 'wpdc_comment_body', 'osi_wpdc_comment_body', 10, 1 ); + +/** + * Save form data to a custom post type. + * + * @param WPCF7_ContactForm $contact_form The Contact Form 7 instance. + * + * @return void + */ +function osi_save_form_data_to_cpt( WPCF7_ContactForm $contact_form ): void { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found + $submission = WPCF7_Submission::get_instance(); + + if ( $submission ) { + $data = $submission->get_posted_data(); + + $post_id = wp_insert_post( + array( + 'post_title' => $data['your-name'], + 'post_type' => 'supporter', + 'post_status' => 'pending', + ) + ); + + // If we have a wp_error, abort. + if ( is_wp_error( $post_id ) ) { + return; + } + + if ( $post_id ) { + update_field( 'name', $data['your-name'], $post_id ); + update_field( 'organization', $data['your-org'], $post_id ); + update_field( 'endorsement_type', $data['your-endorsement'], $post_id ); + update_field( 'quote', $data['your-message'], $post_id ); + } + } +} +add_action( 'wpcf7_before_send_mail', 'osi_save_form_data_to_cpt' );