sanitize_email($_POST['email_address']), 'post_type' => 'email-account', 'post_status' => 'publish' ); $meta_fields = [ 'domain_id', 'mail_password', 'full_name', 'email_signature', 'email_provider', 'smtp_password', 'smtp_server', 'smtp_port', 'imap_password', 'imap_server', 'imap_port' ]; if (isset($_POST['post_id']) && !empty($_POST['post_id'])) { $post_data['ID'] = intval($_POST['post_id']); $post_id = wp_update_post($post_data); $new_post = false; $message = ['status' => 'success', 'message' => 'Email account updated successfully.']; } else { $post_id = wp_insert_post($post_data); $message = ['status' => 'success', 'message' => 'Email account added successfully.']; } if (!is_wp_error($post_id)) { foreach ($meta_fields as $field) { if (isset($_POST[$field])) { update_post_meta($post_id, $field, sanitize_text_field($_POST[$field])); } } // include new accounts in the warmup pool and set the owner_id to the creator of the post if ($new_post) { update_post_meta($post_id, 'owner_id', $current_user_id); update_post_meta($post_id, 'include_in_warmup_pool', $current_user_id); } } else { $message = ['status' => 'error', 'message' => 'Error: ' . $post_id->get_error_message()]; } if ( !(isset($_POST['stay_on_page']) && ($_POST['stay_on_page'] === 'on')) ) { // log_to_file("Email Account Edit template - stay_on_page not set; redirecting!"); wp_redirect( get_permalink( $post_id ) ); exit; } } // Get existing post data if editing if (isset($_GET['edit'])) { $post_id = intval($_GET['edit']); $new_post = false; } else { $post_id = 0; } $email_data = [ 'email_address' => '', 'domain_id' => '', 'mail_password' => '', 'full_name' => '', 'email_signature' => '', 'email_provider' => '', 'smtp_password' => '', 'smtp_server' => '', 'smtp_port' => '', 'imap_password' => '', 'imap_server' => '', 'imap_port' => '' ]; if ($post_id > 0) { $post_item = get_post($post_id); if ($post_item && $post_item->post_type === 'email-account') { $email_data['email_address'] = $post_item->post_title; foreach ($email_data as $key => $value) { if ($key !== 'email_address') { $email_data[$key] = get_post_meta($post_id, $key, true); } } } } // Get domains for current user $domains = get_posts([ 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'domain', 'posts_per_page' => -1, 'meta_query' => [ [ 'key' => 'owner_id', 'value' => $current_user_id ] ] ]); // Get email providers $providers = get_posts([ 'orderby' => 'title', 'order' => 'ASC', 'post_type' => 'email-provider', 'posts_per_page' => -1 ]); get_header(); ?>
>
>
>
>

Advanced Settings