msslrb
Forum Replies Created
-
Thank you! I’ve shared the form export file and main code file.
https://drive.google.com/file/d/1g7tOxBxC5NTXE-qPJVOlsxrhGOC16_Gt/view?usp=drive_link
https://drive.google.com/file/d/13qK8qRUyrhnYJr15fX1KSjAIaiRRqDWa/view?usp=sharing
Sorry, I accidentally eft the important part out. I’m not sure if I’m using deprecated hooks or if it’s an address issue.
// 1. Capture the Entry ID
add_action( 'forminator_custom_form_submit_before_set_fields', function( $entry, $form_id, $field_data_array ) {
$_POST['actual_submission_id'] = $entry->entry_id;
}, 20, 3 );
// 2. Hook into submission
add_action('forminator_form_after_save_entry', 'process_petition_submission', 10, 2);
add_action('forminator_form_after_handle_submit', 'process_petition_submission', 10, 2);
function process_petition_submission($form_id, $response) {
$entry_id = isset($_POST['actual_submission_id']) ? absint($_POST['actual_submission_id']) : 0;
if (!$entry_id && isset($response['entry_id'])) $entry_id = absint($response['entry_id']);
if (!$entry_id) return;
global $wpdb;
if (!class_exists('Forminator_API')) return;
$entry = Forminator_API::get_entry((int)$form_id, (int)$entry_id);
if (is_wp_error($entry) || !$entry) return;
$data = [];
foreach ($entry->meta_data as $field) {
$slug = $field['name'] ?? '';
$value = $field['value'] ?? '';
if (!$slug) continue;
if (is_array($value)) {
$value = implode(', ', array_filter($value));
}
$data[$slug] = $value;
}
// INSERT INTO MAIN PETITIONS TABLE
$wpdb->insert(
$wpdb->prefix . 'petitions',
[
'form_id' => $form_id,
'submission_id' => $entry_id,
'first_name' => sanitize_text_field($data['first_name'] ?? ''),
'last_name' => sanitize_text_field($data['last_name'] ?? ''),
'credentials' => sanitize_text_field($data['credentials'] ?? ''),
'email' => sanitize_email($data['email'] ?? ''),
'phone' => sanitize_text_field($data['phone'] ?? ''),
'p_name' => sanitize_text_field($data['p_name'] ?? ''),
'p_address' => sanitize_text_field($data['p_address'] ?? ''),
'created_at' => current_time('mysql')
]
);
$petition_row_id = $wpdb->insert_id;
// INSERT INTO CONCERNS TABLE
if ($petition_row_id) {
$concerns_table = $wpdb->prefix . 'petition_concerns';
foreach ($data as $key => $value) {
if (strpos($key, 'concern_') === 0 && !empty($value)) {
$wpdb->insert($concerns_table, [
'petition_id' => $petition_row_id,
'concern_group' => $key,
'concern_value' => sanitize_text_field($value),
'created_at' => current_time('mysql')
]);
}
}
}
// 3. Handle Transient for redirect pages
$petitions = get_posts([
'post_type' => 'petition',
'numberposts' => 1,
'meta_query' => [['key' => '_form_id', 'value' => $form_id]]
]);
if (!empty($petitions)) {
$petition_post_id = $petitions[0]->ID;
set_transient('petition_last_entry_' . $petition_post_id, $entry_id, 10 * MINUTE_IN_SECONDS);
}
}Forum: Fixing WordPress
In reply to: Calendar/Table headingsThank you so much! I didn’t know if I had come to the right place for help.
Forum: Fixing WordPress
In reply to: Calendar/Table headingsForum: Plugins
In reply to: [Contact Form 7 Database + | CFDB+] exporting imageAlternatively, is there a way to get a print friendly version of the Contactic datatable from the backend?
Forum: Plugins
In reply to: [Contact Form 7] htmlOkay. I created custom form tags. The field populates correctly. However, I’m still unable to add it to the email template and make it required.
Forum: Plugins
In reply to: [Contact Form 7] htmlThe form works fine. It just doesn’t give the validation error.
I would like to know how to add any html field submission to the email that I received when a form is submitted.
Forum: Plugins
In reply to: [Connections Business Directory] User can edit others postsThank you
Forum: Plugins
In reply to: [Connections Business Directory] User can edit others postsI only see an option to edit. Add Entry, Edit Entry, and Delete Entry are selected under Role. If I click on the Edit My Entry link, it pulls up the form to edit. I don’t see a delete option.
Forum: Plugins
In reply to: [Connections Business Directory] User can edit others postsI have it working now. Can a user only have 1 listing? If I hit View My Directory Entry, it only pulls up the first one entered.
Forum: Plugins
In reply to: [Advanced Classifieds & Directory Pro] Function RequestWe just did a test run and it is nearly impossible to add a listing because of the long list of locations. Do you have another option other than the dropdown.
Forum: Plugins
In reply to: [Advanced Classifieds & Directory Pro] Parent locationThank you! I got it to display the parent location. However, it displays the parent location of the post before it instead of the current post. Do you know how to correct this in my code?
$term_id = $location->parent;
if ( $has_location && $locations = wp_get_object_terms( $post->ID, ‘acadp_locations’ ) ) {
$location_links = array();
foreach ( $locations as $location ) {
$location_links[] = sprintf( ‘%s‘, esc_url(acadp_get_location_page_link( $location ) ), esc_html( $location->name ) ).”, “.$term_name = get_term( $term_id )->name;
}