Author panel
if ( is_user_logged_in() ) {
add_action('wp_head', 'artdir_jquery', 8);
// убираем магические кавычки
function stripslashes_array($array) { return is_array($array) ? array_map('stripslashes_array', $array) : stripslashes($array); }
if (get_magic_quotes_gpc()) { $_POST = stripslashes_array($_POST); }
global $current_user;
get_currentuserinfo();
$options = get_option('article_directory');
$uri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$apl = get_permalink($options['author_panel_id']);
$profile = '';
if (get_option('permalink_structure') == '') {
$profile = '&profile';
} else {
$profile = '?profile';
}
$authorNav = "\r\n\r\n" . '
‘ . get_the_title() . ‘
‘ . “\r\n\r\n”;
$authorNav .= ‘
‘ . “\r\n\r\n”;
// профиль
if (isset($_GET['profile']) || isset($_GET['updated'])) {
$error = ”;
if ($_POST['action'] == ‘updateProfile’) {
require_once( ABSPATH . WPINC . ‘/registration.php’);
global $demo;
if (!$demo) {
if(isset($_POST['display_name'])) {
wp_update_user(array(‘ID’ => $current_user->ID, ‘display_name’ => $_POST['display_name']));
}
}
if(empty($_POST['user_email'])) {
$error .= ‘
‘;
} elseif (!is_email($_POST['user_email'])) {
$error .= ‘
‘;
} else {
if (!$demo) {
wp_update_user(array(‘ID’ => $current_user->ID, ‘user_email’ => $_POST['user_email']));
}
}
if (!$demo) {
if(isset($_POST['url'])) {
wp_update_user(array(‘ID’ => $current_user->ID, ‘user_url’ => $_POST['url']));
}
}
if (!$demo) {
if(isset($_POST['description'])) {
wp_update_user(array(‘ID’ => $current_user->ID, ‘description’ => strip_tags($_POST['description'])));
}
}
if (empty($_POST['pass1']) && !empty($_POST['pass2']) or !empty($_POST['pass1']) && empty($_POST['pass2']) or !empty($_POST['pass1']) && !empty($_POST['pass2'])) {
if ($_POST['pass1'] != $_POST['pass2']) {
$error .= ‘
‘;
} else {
if (!$demo) {
wp_update_user(array(‘ID’ => $current_user->ID, ‘user_pass’ => esc_attr( $_POST['pass1'])));
}
}
}
if (!$error) {
if (strpos($uri, ‘&updated’) === false ) {
wp_redirect($uri . ‘&updated’);
} else {
wp_redirect($uri);
}
exit;
} else {
$error = $error;
}
}
get_header();
echo $authorNav;
if (isset($_GET['updated'])) {
if (!$error) echo ‘
‘;
}
if ($error) echo ‘
‘;
?>