function rcl_send_notify_messages() { global $wpdb; $mess = $wpdb->get_results("SELECT author_mess,adressat_mess,time_mess FROM " . RCL_PREF . "private_message WHERE status_mess='0' && time_mess > date_sub(now(), interval 1 hour)"); if (!$mess) { return false; } foreach ($mess as $m) { $arrs[$m->adressat_mess][$m->author_mess] = $m->time_mess; } foreach ($arrs as $add_id => $vals) { $mess = ''; $to = get_the_author_meta('user_email', $add_id); $cnt = count($vals); foreach ($vals as $auth_id => $time) { $url = rcl_format_url(get_author_posts_url($auth_id), 'privat'); $mess .= '<div style="overflow:hidden;clear:both;"> <p>' . __('You were sent a private message', 'wp-recall') . '</p> <div style="float:left;margin-right:15px;">' . get_avatar($auth_id, 60) . '</div>' . '<p>' . __('from the user', 'wp-recall') . ' ' . get_the_author_meta('display_name', $auth_id) . '</p>' . '<p>' . __('You can read the message by clicking on the link:', 'wp-recall') . ' <a href="' . $url . '">' . $url . '</a></p>' . '</div>'; } if ($cnt == 1) { $title = __('For you', 'wp-recall') . ' ' . $cnt . ' ' . __('new message', 'wp-recall'); } else { $title = __('For you', 'wp-recall') . ' ' . $cnt . ' ' . __('new messages', 'wp-recall'); } rcl_mail($to, $title, $mess); } }
function navi() { global $post, $group_id, $user_LK; $class = 'rcl-navi'; $page_navi = ''; if ($group_id) { $prm = get_term_link((int) $group_id, 'groups'); if ($_GET['group-page']) { $prm = rcl_format_url($prm) . 'group-page=' . $_GET['group-page']; } } else { if ($user_LK) { $prm = get_author_posts_url($user_LK); } else { if (isset($post)) { $prm = get_permalink($post->ID); } } } if ($this->inpage && $this->cnt_data > $this->inpage) { if (isset($prm)) { $redirect_url = rcl_format_url($prm); } else { $redirect_url = '#'; } if ($redirect_url == '#' || $group_id) { $class .= ' ajax-navi'; } $page_navi = '<div class="' . $class . '">'; $next = $this->navi + 3; $prev = $this->navi - 4; if ($prev == 1) { $page_navi .= '<a href="' . $redirect_url . $this->g_name . '=1' . $this->get . '">1</a>'; } for ($a = 1; $a <= $this->num_page; $a++) { if ($a == 1 && $a <= $prev && $prev != 1) { $page_navi .= '<a href="' . $redirect_url . $this->g_name . '=1' . $this->get . '">1</a> ... '; } if ($prev < $a && $a <= $next) { if ($this->navi == $a) { $page_navi .= '<span>' . $a . '</span>'; } else { $page_navi .= '<a href="' . $redirect_url . $this->g_name . '=' . $a . '' . $this->get . '">' . $a . '</a>'; } } } if ($next < $this->num_page && $this->num_page != $next + 1) { $page_navi .= ' ... <a href="' . $redirect_url . 'navi=' . $this->num_page . '' . $this->get . '">' . $this->num_page . '</a>'; } if ($this->num_page == $next + 1) { $page_navi .= '<a href="' . $redirect_url . $this->g_name . '=' . $this->num_page . '' . $this->get . '">' . $this->num_page . '</a>'; } $page_navi .= '</div>'; } return $page_navi; }
function rcl_orders($author_lk) { global $wpdb, $user_ID, $rmag_options, $rcl_options, $order; if ($user_ID != $author_lk) { return false; } $block = apply_filters('content_order_tab', ''); if (isset($_GET['order-id'])) { $order = rcl_get_order($_GET['order-id']); if ($order->order_author != $user_ID) { return false; } $status = $order->order_status; $order_id = $order->order_id; $price = $order->order_price; $block .= '<a class="recall-button view-orders" href="' . rcl_format_url(get_author_posts_url($author_lk), 'orders') . '">Смотреть все заказы</a>'; $block .= '<h3>Заказ №' . $order_id . '</h3>'; $block .= '<div id="manage-order">'; if ($status == 1 || $status == 5) { $block .= '<input class="remove_order recall-button" onclick="rcl_trash_order(this);return false;" type="button" name="remove_order" data-order="' . $order_id . '" value="Удалить">'; } if ($status == 1 && function_exists('rcl_payform')) { $type_pay = $rmag_options['type_order_payment']; if ($type_pay == 1 || $type_pay == 2) { $block .= rcl_payform(array('id_pay' => $order_id, 'summ' => $price, 'type' => 2)); } else { $block .= '<input class="pay_order recall-button" onclick="rcl_pay_order_private_account(this);return false;" type="button" name="pay_order" data-order="' . $order_id . '" value="Оплатить">'; } } $block .= '</div>'; $block .= '<div class="redirectform"></div>'; $block .= rcl_get_include_template('order.php', __FILE__); } else { global $orders; $orders = rcl_get_orders(array('user_id' => $user_ID, 'status_not_in' => 6)); if (!$orders) { $block .= '<p>У вас пока не оформлено ни одного заказа.</p>'; } else { $block .= rcl_get_include_template('orders-history.php', __FILE__); } } return $block; }
function rcl_post_group_edit_button($content) { global $post, $user_ID, $rcl_group, $rcl_options; if (!is_tax('groups')) { return $content; } if (rcl_is_group_can('moderator')) { $edit_url = rcl_format_url(get_permalink($rcl_options['public_form_page_rcl'])); $content = '<p class="post-edit-button">' . '<a title="' . __('Edit', 'wp-recall') . '" object-id="none" href="' . $edit_url . 'rcl-post-edit=' . $post->ID . '">' . '<i class="fa fa-pencil-square-o"></i>' . '</a>' . '</p>' . $content; } return $content; }
function send_mail($order_custom_field, $table_order, $user_id = false, $args = false) { global $user_ID, $rmag_options, $rcl_options; if (!$user_id) { $user_id = $user_ID; } $reg_user = $rmag_options['noreg_order'] ? false : true; $subject = 'Данные заказа №' . $this->order_id; $textmail = ' <p>Пользователь сформировал заказ в магазине "' . get_bloginfo('name') . '".</p> <h3>Информация о пользователе:</h3> <p><b>Имя</b>: ' . get_the_author_meta('display_name', $user_id) . '</p> <p><b>Email</b>: ' . get_the_author_meta('user_email', $user_id) . '</p> <h3>Данные полученные при оформлении:</h3> ' . $order_custom_field . ' <p>Заказ №' . $this->order_id . ' получил статус "Не оплачено".</p> <h3>Детали заказа:</h3> ' . $table_order . ' <p>Ссылка для управления заказом в админке:</p> <p>' . admin_url('admin.php?page=manage-rmag&order-id=' . $this->order_id) . '</p>'; $admin_email = $rmag_options['admin_email_magazin_recall']; if ($admin_email) { rcl_mail($admin_email, $subject, $textmail); } else { $users = get_users(array('role' => 'administrator')); foreach ((array) $users as $userdata) { $email = $userdata->user_email; rcl_mail($email, $subject, $textmail); } } $email = get_the_author_meta('user_email', $user_id); $textmail = ''; if ($args && $reg_user) { $subject = 'Данные вашего аккаунта и заказа №' . $this->order_id; if ($rcl_options['confirm_register_recall'] == 1) { $url = get_bloginfo('wpurl') . '/?rglogin='******'user_login'] . '&rgpass='******'user_password'] . '&rgcode=' . md5($args['user_login']); $textmail .= '<h3>Вы были зарегистрированы</h3> <p>Подтвердите свою электронную почту на сайте перейдя по ссылке ниже:</p> <p><a href="' . $url . '">' . $url . '</a></p> <p>Не получается активировать аккаунт?</p> <p>Скопируйте текст ссылки ниже, вставьте его в адресную строку вашего браузера и нажмите Enter</p>'; } $textmail .= '<h3>Данные аккаунта</h3> <p>Для вас был создан личный кабинет покупателя, где вы сможете следить за сменой статусов ваших заказов, формировать новые заказы и оплачивать их доступными способами</p> <p>Ваши данные для авторизации в вашем личном кабинете:</p> <p>Логин: ' . $args['user_login'] . '</p> <p>Пароль: ' . $args['user_password'] . '</p> <p>В дальнейшем используйте свой личный кабинет для новых заказов на нашем сайте.</p>'; } $textmail .= ' <p>Вы сформировали заказ в магазине "' . get_bloginfo('name') . '".</p> <h3>Детали заказа</h3> <p>Заказ №' . $this->order_id . ' получил статус "Не оплачено".</p> ' . $table_order; $link = rcl_format_url(get_author_posts_url($user_id), 'orders'); $textmail .= '<p>Ссылка для управления заказами: <a href="' . $link . '">' . $link . '</a></p>'; $mail = array('email' => $email, 'user_id' => $user_id, 'content' => $textmail, 'subject' => $subject); $maildata = apply_filters('mail_insert_order_rcl', $mail, $this->order_id); rcl_mail($maildata['email'], $maildata['subject'], $maildata['content']); }
function delete_private_message_recall() { global $wpdb, $user_ID; if (!isset($_GET['delete_private_message_recall'])) { return false; } if (!wp_verify_nonce($_GET['_wpnonce'], $user_ID)) { wp_die('Error'); } $user_id = $_GET['user_id']; $id_mess = $_GET['id_mess']; $result = $wpdb->query($wpdb->prepare("DELETE FROM " . RCL_PREF . "private_message WHERE ID = '%d'", $id_mess)); if (!$result) { wp_die('Error'); } wp_redirect(rcl_format_url(get_author_posts_url($user_id), 'privat')); exit; }
function rcl_get_button_tab($args, $button = false) { global $rcl_options, $user_LK; $link = rcl_format_url(get_author_posts_url($user_LK), $args['id_tab']); /*if(!$button) $status = 'active'; else $status = '';*/ //var_dump($button); $html_button = rcl_get_button($args['name'], $link, array('class' => rcl_get_class_button_tab($button, $args['id_tab']), 'icon' => $args['class'])); $button .= apply_filters('rcl_get_button_tab', $html_button, $args); return $button; }
function get_filters($count_users = false) { global $post, $user_LK, $active_addons; if (!$this->filters) { return false; } $content = ''; if ($this->search_form) { $content = apply_filters('users_search_form_rcl', $content); } $count_users = false !== $count_users ? $count_users : $this->count_users(); $content .= '<h3>' . __('Total users', 'wp-recall') . ': ' . $count_users . '</h3>'; if (isset($this->add_uri['users-filter'])) { unset($this->add_uri['users-filter']); } $s_array = $this->search_request(); $rqst = $s_array ? implode('&', $s_array) . '&' : ''; $url = $user_LK ? get_author_posts_url($user_LK) : get_permalink($post->ID); $perm = rcl_format_url($url) . $rqst; $filters = array('time_action' => __('Activity', 'wp-recall'), 'posts_count' => __('Publications', 'wp-recall'), 'comments_count' => __('Comments', 'wp-recall'), 'user_registered' => __('Registration', 'wp-recall')); if (isset($active_addons['rating-system'])) { $filters['rating_total'] = __('Rated', 'wp-recall'); } $filters = apply_filters('rcl_users_filter', $filters); $content .= '<div class="rcl-data-filters">' . __('Filter by', 'wp-recall') . ': '; foreach ($filters as $key => $name) { $content .= $this->get_filter($key, $name, $perm); } $content .= '</div>'; return $content; }
function delete_review() { global $wpdb, $user_ID, $rcl_options; if ($user_ID) { $recall_id = intval($_POST['recall_id']); $user_id = intval($_POST['user_id']); $review = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . RCL_PREF . "profile_otziv WHERE ID = '%d'", $recall_id)); $result = $wpdb->query($wpdb->prepare("DELETE FROM " . RCL_PREF . "profile_otziv WHERE ID = '%d'", $recall_id)); if ($result) { do_action('rcl_delete_review', $review); wp_redirect(rcl_format_url(get_author_posts_url($user_id), 'recall')); exit; } else { wp_die('Error'); } } }
function rcl_delete_avatar_action() { global $wpdb, $user_ID, $rcl_avatar_sizes; if (!isset($_GET['rcl-action']) || $_GET['rcl-action'] != 'delete_avatar') { return false; } if (!wp_verify_nonce($_GET['_wpnonce'], $user_ID)) { wp_die('Error'); } $result = delete_user_meta($user_ID, 'rcl_avatar'); if (!$result) { wp_die('Error'); } $dir_path = RCL_UPLOAD_PATH . 'avatars/'; foreach ($rcl_avatar_sizes as $key => $size) { unlink($dir_path . $user_ID . '-' . $size . '.jpg'); } unlink($dir_path . $user_ID . '.jpg'); wp_redirect(rcl_format_url(get_author_posts_url($user_ID)) . 'rcl-avatar=deleted'); exit; }
<ul class="left-recall-menu"> <?php if (is_user_logged_in() && current_user_can('activate_plugins')) { // если залогинен и есть полномочия (тот, кто может активировать плагины - явно большой босс) echo '<li><a href="/"><i class="fa fa-home"></i><span>' . __('Home') . '</span></a></li>' . '<li><a href="' . admin_url() . '"><i class="fa fa-external-link-square"></i><span>' . __('Dashboard') . '</span></a></li>' . '<li><a href="' . $rcl_user_URL . '"><i class="fa fa-user"></i><span>' . __('Personal cabinet', 'wp-recall') . '</span></a></li>' . '<li><a href="' . esc_url(wp_logout_url('/')) . '"><i class="fa fa-sign-out"></i><span>' . __('Log Out') . '</span></a></li>'; } else { if (is_user_logged_in()) { // если это обычный залогиненный пользователь echo '<li><a href="/"><i class="fa fa-home"></i><span>' . __('Home') . '</span></a></li>' . '<li><a href="' . $rcl_user_URL . '"><i class="fa fa-user"></i><span>' . __('Personal cabinet', 'wp-recall') . '</span></a></li>' . '<li><a href="' . esc_url(wp_logout_url('/')) . '"><i class="fa fa-sign-out"></i><span>' . __('Log Out') . '</span></a></li>'; } else { // если гость // и в настройках выбрано: if ($rcl_options['login_form_recall'] == 1) { // Каждая загружается отдельно $page_in_out = rcl_format_url(get_permalink($rcl_options['page_login_form_recall'])); // страница с формой входа-регистрации echo '<li><a href="/"><i class="fa fa-home"></i><span>' . __('Home') . '</span></a></li>' . '<li><a href="' . $page_in_out . 'action-rcl=register"><i class="fa fa-book"></i><span>' . __('Register') . '</span></a></li>' . '<li><a href="' . $page_in_out . 'action-rcl=login"><i class="fa fa-sign-in"></i><span>' . __('Entry', 'wp-recall') . '</span></a></li>'; } else { if ($rcl_options['login_form_recall'] == 2) { // Формы Wordpress echo '<li><a href="/"><i class="fa fa-home"></i><span>' . __('Home') . '</span></a></li>'; if (get_option('users_can_register')) { // если в настройках вордпресса разрешена регистрация - выводим echo '<li><a href="' . esc_url(wp_registration_url()) . '"><i class="fa fa-book"></i><span>' . __('Register') . '</span></a></li>'; } echo '<li><a href="' . esc_url(wp_login_url('/')) . '"><i class="fa fa-sign-in"></i><span>' . __('Entry', 'wp-recall') . '</span></a></li>'; } else { if ($rcl_options['login_form_recall'] == 3) { // Форма в виджете echo '<li><a href="/"><i class="fa fa-home"></i><span>' . __('Home') . '</span></a></li>';
function rcl_delete_file() { global $user_ID, $rcl_options; if (!isset($_GET['rcl-delete-file'])) { return false; } $id_file = base64_decode($_GET['rcl-delete-file']); if (!$user_ID || !wp_verify_nonce($_GET['_wpnonce'], 'user-' . $user_ID)) { return false; } $file = get_post($id_file); if (!$file) { wp_die(__('File does not exist on the server!', 'wp-recall')); } wp_delete_attachment($file->ID); if ($file->post_parent) { wp_redirect(rcl_format_url(get_permalink($rcl_options['public_form_page_rcl'])) . 'rcl-post-edit=' . $file->post_parent); } else { wp_redirect(rcl_format_url(get_author_posts_url($user_ID), 'profile') . '&file=deleted'); } exit; }
function get_filters($count_groups = false) { global $post, $active_addons, $user_LK; if (!$this->filters) { return false; } $content = ''; $count_groups = false !== $count_groups ? $count_groups : $this->count_feed_posts(); //$content .='<h3>'.__('Total groups','wp-recall').': '.$count_groups.'</h3>'; if (isset($this->add_uri['feed-filter'])) { unset($this->add_uri['feed-filter']); } $s_array = $this->search_request(); $rqst = $s_array ? implode('&', $s_array) . '&' : ''; $url = $user_LK ? get_author_posts_url($user_LK) : get_permalink($post->ID); $perm = rcl_format_url($url) . $rqst; $filters = array('posts' => __('News', 'wp-recall'), 'comments' => __('Comments', 'wp-recall'), 'answers' => __('Answers', 'wp-recall')); $filters = apply_filters('rcl_feed_filter', $filters); $content .= '<div class="rcl-data-filters">'; foreach ($filters as $key => $name) { $content .= $this->get_filter($key, $name, $perm); } $content .= '</div>'; return $content; }
function rcl_get_authorize_form($type = false, $form = false) { global $user_ID, $rcl_user_URL, $rcl_options, $typeform; $typeform = $form; ob_start(); echo '<div class="panel_lk_recall ' . $type . '">'; if ($type == 'floatform') { echo '<a href="#" class="close-popup"><i class="fa fa-times-circle"></i></a>'; } if ($user_ID) { echo '<div class="username"><b>' . __('Hi', 'wp-recall') . ', ' . get_the_author_meta('display_name', $user_ID) . '!</b></div> <div class="author-avatar">'; echo '<a href="' . $rcl_user_URL . '" title="' . __('In personal account', 'wp-recall') . '">' . get_avatar($user_ID, 60) . '</a>'; if (function_exists('rcl_rating_block')) { echo rcl_rating_block(array('ID' => $user_ID, 'type' => 'user')); } echo '</div>'; echo '<div class="buttons">'; $buttons = '<p>' . rcl_get_button(__('In personal account', 'wp-recall'), $rcl_user_URL, array('icon' => 'fa-home')) . '</p> <p>' . rcl_get_button(__('Exit', 'wp-recall'), wp_logout_url(home_url()), array('icon' => 'fa-external-link')) . '</p>'; echo apply_filters('buttons_widget_rcl', $buttons); echo '</div>'; } else { $login_form = isset($rcl_options['login_form_recall']) ? $rcl_options['login_form_recall'] : 0; if ($login_form == 1 && $type != 'pageform') { $redirect_url = rcl_format_url(get_permalink($rcl_options['page_login_form_recall'])); echo '<div class="buttons">'; $buttons = '<p>' . rcl_get_button(__('Entry', 'wp-recall'), $redirect_url . 'action-rcl=login', array('icon' => 'fa-sign-in')) . '</p> <p>' . rcl_get_button(__('Registration', 'wp-recall'), $redirect_url . 'action-rcl=register', array('icon' => 'fa-book')) . '</p>'; echo apply_filters('buttons_widget_rcl', $buttons); echo '</div>'; } else { if ($login_form == 2) { echo '<div class="buttons">'; $buttons = '<p>' . rcl_get_button(__('Entry', 'wp-recall'), esc_url(wp_login_url('/')), array('icon' => 'fa-sign-in')) . '</p> <p>' . rcl_get_button(__('Registration', 'wp-recall'), esc_url(wp_registration_url()), array('icon' => 'fa-book')) . '</p>'; echo apply_filters('buttons_widget_rcl', $buttons); echo '</div>'; } else { if ($login_form == 3 || $type) { if ($typeform != 'register') { rcl_include_template('form-sign.php'); } if ($typeform != 'sign') { rcl_include_template('form-register.php'); } if (!$typeform || $typeform == 'sign') { rcl_include_template('form-remember.php'); } } else { if (!$login_form) { echo '<div class="buttons">'; $buttons = '<p>' . rcl_get_button(__('Entry', 'wp-recall'), '#', array('icon' => 'fa-sign-in', 'class' => 'rcl-login')) . '</p> <p>' . rcl_get_button(__('Registration', 'wp-recall'), '#', array('icon' => 'fa-book', 'class' => 'rcl-register')) . '</p>'; echo apply_filters('buttons_widget_rcl', $buttons); echo '</div>'; } } } } } echo '</div>'; $html = ob_get_contents(); ob_end_clean(); return $html; }
function get_filters($count_groups = false) { global $post, $active_addons, $user_LK; if (!$this->filters) { return false; } $search_text = isset($_GET['group-name']) ? $_GET['group-name'] : ''; $content = '<div class="rcl-search-form"> <form method="get" action=""> <p>' . __('Search groups', 'wp-recall') . '</p> <input type="text" name="group-name" value="' . $search_text . '"> <input type="submit" class="recall-button" value="' . __('Search', 'wp-recall') . '"> </form> </div>'; if ($this->search_form) { $content = apply_filters('rcl_groups_search_form', $content); } $count_groups = false !== $count_groups ? $count_groups : $this->count_groups(); $content .= '<h3>' . __('Total groups', 'wp-recall') . ': ' . $count_groups . '</h3>'; if (isset($this->add_uri['groups-filter'])) { unset($this->add_uri['groups-filter']); } $s_array = $this->search_request(); $rqst = $s_array ? implode('&', $s_array) . '&' : ''; $url = $user_LK ? get_author_posts_url($user_LK) : get_permalink($post->ID); $perm = rcl_format_url($url) . $rqst; $filters = array('name' => __('Name', 'wp-recall'), 'term_id' => __('Date', 'wp-recall'), 'count' => __('Publications', 'wp-recall'), 'group_users' => __('Users', 'wp-recall')); $filters = apply_filters('rcl_groups_filter', $filters); $content .= '<div class="rcl-data-filters">' . __('Filter by', 'wp-recall') . ': '; foreach ($filters as $key => $name) { $content .= $this->get_filter($key, $name, $perm); } $content .= '</div>'; return $content; }
<table> <tr> <th>Номер заказа</th> <th>Дата заказа</th> <th>Количество товаров</th> <th>Сумма</th> <th>Статус заказа</th> </tr> <?php foreach ($orders as $data) { rcl_setup_orderdata($data); ?> <tr> <td> <a href="<?php echo rcl_format_url(get_author_posts_url($user_ID), 'orders'); ?> &order-id=<?php rcl_order_ID(); ?> "> <?php rcl_order_ID(); ?> </a> </td> <td><?php rcl_order_date(); ?> </td> <td><?php
function rcl_edit_post_link($admin_url, $post_id) { global $user_ID, $rcl_options; get_currentuserinfo(); if (!isset($rcl_options['front_editing'])) { $rcl_options['front_editing'] = array(0); } $access = isset($rcl_options['consol_access_rcl']) && $rcl_options['consol_access_rcl'] ? $rcl_options['consol_access_rcl'] : 7; $user_info = get_userdata($user_ID); if (array_search($user_info->user_level, $rcl_options['front_editing']) !== false || $user_info->user_level < $access) { $edit_url = rcl_format_url(get_permalink($rcl_options['public_form_page_rcl'])); return $edit_url . 'rcl-post-edit=' . $post_id; } else { return $admin_url; } }
function rcl_get_current_url($typeform = false, $urlform = 0) { $protocol = @($_SERVER["HTTPS"] != 'on') ? 'http://' : 'https://'; $url = $protocol . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; if (false !== strpos($url, '?action-rcl')) { $matches = ''; preg_match_all('/(?<=http\\:\\/\\/)[A-zА-я0-9\\/\\.\\-\\s\\ё]*(?=\\?action\\-rcl)/iu', $url, $matches); $host = $matches[0][0]; } if (false !== strpos($url, '&action-rcl')) { preg_match_all('/(?<=http\\:\\/\\/)[A-zА-я0-9\\/\\.\\_\\-\\s\\ё]*(&=\\&action\\-rcl)/iu', $url, $matches); $host = $matches[0][0]; } if (!isset($host) || !$host) { $host = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; } $host = $protocol . $host; if ($urlform) { $host = rcl_format_url($host) . 'action-rcl=' . $typeform; } if ($typeform == 'remember') { $host = rcl_format_url($host) . 'action-rcl=remember&success=true'; } return $host; }
function rcl_register_user_order() { global $rmag_options, $wpdb, $order, $rcl_options; $reg_user = $rmag_options['noreg_order'] ? false : true; $fio_new_user = sanitize_text_field($_POST['fio_new_user']); $email_new_user = sanitize_email($_POST['email_new_user']); include_once 'rcl_order.php'; $ord = new Rcl_Order(); $get_fields = get_option('custom_profile_field'); $get_order_fields = get_option('custom_orders_field'); $req_prof = $ord->chek_requared_fields($get_fields, 'profile'); $req_order = $ord->chek_requared_fields($get_order_fields); if ($email_new_user && $req_prof && $req_order) { $res_email = email_exists($email_new_user); $res_login = username_exists($email_new_user); $correctemail = is_email($email_new_user); $valid = validate_username($email_new_user); if (!$reg_user && (!$correctemail || !$valid)) { if (!$valid || !$correctemail) { $log['int'] = 1; $log['recall'] = '<p style="text-align:center;color:red;">Вы ввели некорректный email!</p>'; echo json_encode($res); exit; } } //var_dump($reg_user);exit; if ($reg_user && ($res_login || $res_email || !$correctemail || !$valid)) { if (!$valid || !$correctemail) { $log['int'] = 1; $log['recall'] .= '<p style="text-align:center;color:red;">Вы ввели некорректный email!</p>'; } if ($res_login || $res_email) { $log['int'] = 1; $log['recall'] .= '<p style="text-align:center;color:red;">Этот email уже используется!<br>' . 'Если это ваш email, то авторизуйтесь и продолжите оформление заказа.</p>'; } } else { $user_id = false; if (!$reg_user) { $user = get_user_by('email', $email_new_user); if ($user) { $user_id = $user->ID; } } if (!$user_id) { $random_password = wp_generate_password($length = 12, $include_standard_special_chars = false); $userdata = array('user_pass' => $random_password, 'user_login' => $email_new_user, 'user_email' => $email_new_user, 'display_name' => $fio_new_user); $user_id = rcl_insert_user($userdata); } if ($user_id) { if ($get_fields && $user_id) { $cf = new Rcl_Custom_Fields(); $cf->register_user_metas($user_id); } //Сразу авторизуем пользователя if ($reg_user && !$rcl_options['confirm_register_recall']) { $creds = array(); $creds['user_login'] = $email_new_user; $creds['user_password'] = $random_password; $creds['remember'] = true; $user = wp_signon($creds, false); $redirect_url = rcl_format_url(get_author_posts_url($user_id), 'orders'); } else { $redirect_url = false; } $order_id = $ord->get_order_id(); $results = $ord->insert_order($order_id, $user_id); if (!$results) { $log['int'] = 1; $log['recall'] = '<p style="text-align:center;color:red;">Возникла ошибка, заказ не был создан!</p>'; echo json_encode($log); exit; } $order_custom_field = $ord->insert_detail_order($get_order_fields); $order = rcl_get_order($order_id); $table_order = rcl_get_include_template('order.php', __FILE__); $ord->send_mail($order_custom_field, $table_order, $user_id, $creds); $notice = $rcl_options['confirm_register_recall'] == 1 ? '<p class=res_confirm style="color:orange;">Для отслеживания статуса заказа подтвердите указанный email!<br>' . 'Перейдите по ссылке в высланном письме.</p>' : ''; if (!$order->order_price) { //Если заказ бесплатный $notice .= "<p class='res_confirm'>Ваш заказ был создан!<br />" . "Заказ содержал только бесплатные товары<br>" . "Заказу присвоен статус - \"Оплачено\"<br>" . "Заказ поступил в обработку. В своем личном кабинете вы можете узнать статус вашего заказа.</p>"; $log['recall'] = $notice; $log['redirect'] = $redirect_url; $log['int'] = 100; echo json_encode($log); exit; } if (function_exists('rcl_payform')) { $type_order_payment = $rmag_options['type_order_payment']; if ($type_order_payment == 1 || $type_order_payment == 2) { $notice .= "<p class='res_confirm'>Ваш заказ был создан!<br />Заказу присвоен статус - \"Неоплачено\"<br />Вы можете оплатить его сейчас или из своего ЛК. Там же вы можете узнать статус вашего заказа.</p>"; if ($type_order_payment == 2) { $notice .= "<p class='res_confirm'>Вы можете пополнить свой личный счет на сайте из своего личного кабинета и в будущем оплачивать свои заказы через него</p>"; } if (!$rcl_options['confirm_register_recall']) { $notice .= "<p align='center'><a href='" . $redirect_url . "'>Перейти в свой личный кабинет</a></p>"; $notice .= rcl_payform(array('id_pay' => $order_id, 'summ' => $order->order_price, 'user_id' => $user_id, 'type' => 2)); } $log['recall'] = $notice; $log['redirect'] = 0; $log['int'] = 100; } else { $log['int'] = 100; $log['redirect'] = $redirect_url; $notice .= "<p class=res_confirm>Ваш заказ был создан!<br />Проверьте свою почту.</p>"; $log['recall'] = $notice; } } else { $log['int'] = 100; $log['redirect'] = $redirect_url; $notice .= '<p class=res_confirm>Ваш заказ был создан!<br />Проверьте свою почту.</p>'; $log['recall'] = $notice; } } } } else { $log['int'] = 1; $log['recall'] = '<p style="text-align:center;color:red;">Пожалуйста, заполните все обязательные поля!</p>'; } echo json_encode($log); exit; }