🎉 سال نو، مهارت نو، مشاوره رایگان نقشه راه برنامه نویسی (آفر ویژه ثبت نام قبل از افزایش قیمت 🔥)
۰ ثانیه
۰ دقیقه
۰ ساعت
۱ Erfan Tayebi
ارسال نشدن ایمیل
جامعه وردپرس (برنامه نویسی) ایجاد شده در ۱۳ مهر ۱۴۰۰

سلام و عرض ادب کدها رو به این شکل زدم ثبت نام هم انجام میشه اما ایمیل ارسال نمیشه سایت mailtrap.io هم با فیلترشکن باز میشه با توجه به این موضوع ممنون میشم بفرمایید کدها مشکل داره یا اینکه از این سایت نمیشه استفاده کرد ؟ اگر راه و ابزاردیگه ای برای هندل کردن این مورد هست بفرمایید

<h2>General</h2>
<div class="options-form">
    <fieldset>
    <legend>متن ایمیل بعد از ثبت نام کاربر :</legend>
    <div class="form-row">
        <label for="new_user_email_subject"> عنوان ایمیل :</label>
        <input type="text" name="new_user_email_subject" id="new_user_email_subject"
         value="<?php echo isset($options['new_user_email_subject']) ? 
         esc_attr($options['new_user_email_subject']): '' ;?>">
    </div>
    <div class="form-row">
        <label for="new_user_email_content">متن ایمیل:</label>
        <textarea name="new_user_email_content" id="new_user_email_content" cols="30" rows="10">
            <?php echo isset($options['new_user_email_content']) ? 
            $options['new_user_email_content'] : '' ; ?></textarea>
    </div>
    <div class="form-row">
        <button type="submit" name="save_options" class="button">ذخیره سازی</button>   
    </div>
    </fieldset>
</div>
<?php
add_action('admin_menu' , 'clab_add_options_panel');
add_action('admin_enqueue_scripts' , 'clab_options_panel_assets');
add_action('clab_save_options' , 'clab_handle_options');
function clab_options_panel_assets()
{
    wp_register_style('options_panel_style' , CLAB_URL . 'options-panel/assets/css/options-panel.css');
    wp_register_script('options-panel-script' , CLAB_URL .'options-panel/assets/js/options-panel.js' );
    wp_enqueue_style('options_panel_style');
    wp_enqueue_script('options-panel-script');
}
function clab_add_options_panel()
{
    add_theme_page('تنظیمات قالب' , 'تنظیمات clab' , 'manage_options' , 'clab_options_panel' , 'clab_show_options_panel');
}
function clab_show_options_panel()
{
    $current_tab = isset($_GET['tab']) && !empty($_GET['tab']) ? 
    sanitize_text_field($_GET['tab']) : 'general' ;
    $whitelist_tabs = ['general' , 'posts' , 'thumbnail' , 'notification'];
    if( !in_array($current_tab , $whitelist_tabs)){
        wp_die('دسترسی به این بخش امکان پذیر نمیباشد');
    }
    if (isset($_POST['save_options'])){
        do_action('clab_save_options' , $current_tab);
    }
    $fonts_list = [
        'وزیر' => 'vazir',
        'صمیم' => 'samim',
        'تنها' => 'tanha'
    ];
    $clab_options = get_option('clab_options' , []);
    $image_sizes = get_intermediate_image_sizes();
    $options = isset($clab_options [$current_tab]) ? $clab_options [$current_tab] : [] ;
    include 'views/index.php';
}
function clab_handle_options($current_tab)
{
    $clab_options = get_option('clab_options' , []);
    switch ($current_tab){
        case 'general':
            $clab_options['general'] = [
                'site_title' => sanitize_text_field($_POST['site_title']),
                'home-posts-count' => intval($_POST['home-posts-count'])> 0 ? intval($_POST['home-posts-count']) : 1
            ];
         break;
        case 'posts':
            $clab_options['posts'] = [
                'show_category' => isset($_POST['show_category']) ? 1 : 0,
                'show_excerpt' => isset($_POST['show_excerpt']) ? 1 : 0,
                'show_comments' => isset($_POST['show_comments']) ? 1 : 0,
                'post_font_family' => sanitize_text_field($_POST['post_font_family'])
            ];
        break;
        case 'thumbnail':
            $clab_options['thumbnail'] = [
                'default_image_size' => sanitize_text_field($_POST['default_image_size'])
            ];
        break;
        case 'notification':
            $clab_options['notification'] = [
                'new_user_email_subject' => sanitize_text_field($_POST['new_user_email_subject']),
                'new_user_email_content' => sanitize_text_field($_POST['new_user_email_content'])
            ];
        break;
    }
    update_option('clab_options' , $clab_options);
}
<?php
function clab_options_panel_css()
    {
        wp_register_style('clab_options_panel_fonts' , CLAB_URL . 'options-panel/assets/css/fonts.css');
        wp_enqueue_style('clab_options_panel_fonts');
        $current_font = clab_get_posts_options('post_font_family');
        if(!empty($current_font))
        {
            $custom_font_style = "
            .blog-post h3 a {
                font-family: {$current_font}
            }
            ";
            wp_add_inline_style('clab_options_panel_fonts' , $custom_font_style);
        }
    }
    add_action('wp_enqueue_scripts' , 'clab_options_panel_css');
    function clab_process_notifications($user_id)
    {
        $email_subject = clab_get_notifications_option('new_user_email_subject');
        $email_content = clab_get_notifications_option('new_user_email_content');
        if(!empty($email_content) && !empty($email_subject)){
            $user = get_user_by('id' , $user_id);
            wp_mail($user -> user_email , $email_subject , $email_content);
        }
    }
    add_action('user_register' , 'clab_process_notifications');
<?php 
function clab_get_general_options($name)
{
    $options = get_option('clab_options');
    $general_options = $options['general'];
    return isset($general_options[$name]) ? $general_options[$name] : null ;
}
function clab_get_posts_options($name)
{
    $options = get_option('clab_options');
    $posts_options = $options['posts'];
    return isset($posts_options[$name]) ? $posts_options[$name] : null ;
}
function clab_get_thumbnails_option($name)
{
    $options = get_option('clab_options');
    $thumbnails_options = $options['thumbnail'];
    return isset($thumbnails_options[$name]) ? $thumbnails_options[$name] : null ;
}
function clab_get_notifications_option($name)
{
    $options = get_option('clab_options');
    $notifications_options = $options['notification'];
    return isset($notifications_options[$name]) ? $notifications_options[$name] : null ;
}
function mailtrap($phpmailer) {
    $phpmailer->isSMTP();
    $phpmailer->Host = 'smtp.mailtrap.io';
    $phpmailer->SMTPAuth = true;
    $phpmailer->Port = 2525;
    $phpmailer->Username = '861785b8807727';
    $phpmailer->Password = '4f92d941a8f688';
  }
  add_action('phpmailer_init', 'mailtrap');

سلام خدمت شما.کدهاتون که مشکل خاصی نداره فقط کدهای بخش تنظیم ایمیل رو در چه فایلی قرار دادید؟

کیوان علی محمدی ۲۵ مهر ۱۴۰۰، ۰۷:۴۱