/**
  *	Process the request
  *	@todo Setting for reassigning user's posts
  */
 public function process()
 {
     // Verify the security nonce and die if it fails
     if (!isset($_POST['wp_delete_user_accounts_nonce']) || !wp_verify_nonce($_POST['wp_delete_user_accounts_nonce'], 'wp_delete_user_accounts_nonce')) {
         wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Request failed security check.', 'wp-delete-user-accounts')));
     }
     // Don't permit admins to delete their own accounts
     if (current_user_can('manage_options')) {
         wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Administrators cannot delete their own accounts.', 'wp-delete-user-accounts')));
     }
     // Get the current user
     $user_id = get_current_user_id();
     // Get user meta
     $meta = get_user_meta($user_id);
     // Delete user's meta
     foreach ($meta as $key => $val) {
         delete_user_meta($user_id, $key);
     }
     // Destroy user's session
     wp_logout();
     // Delete the user's account
     $deleted = wp_delete_user($user_id);
     if ($deleted) {
         // Send success message
         wp_send_json(array('status' => 'success', 'title' => __('Success!', 'wp-delete-user-accounts'), 'message' => __('Your account was successfully deleted. Fair well.', 'wp-delete-user-accounts')));
     } else {
         wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Request failed.', 'wp-delete-user-accounts')));
     }
 }
 public static function process_withdrawal()
 {
     $action = wskl_POST('action');
     if ($action != 'dabory_members_withdrawal') {
         return;
     }
     self::evaluate_and_redirect_if_failed(is_user_logged_in(), __('먼저 로그인 하세요', 'wskl'));
     self::evaluate_and_redirect_if_failed(wp_verify_nonce($_POST['dabory_members_withdrawal'], 'dabory_members_withdrawal'), __('Nonce 인증에 실패했습니다.', 'wskl'));
     $user = wp_get_current_user();
     $password = wskl_POST('password');
     $reason = wskl_POST('reason', 'sanitize_text_field');
     self::evaluate_and_redirect_if_failed(wp_check_password($password, $user->user_pass, $user->ID), __('비밀번호가 일치하지 않습니다.', 'wskl'));
     if (wskl_is_option_enabled('members_delete_after_withdrawal')) {
         if (!function_exists('wp_delete_user')) {
             include_once ABSPATH . 'wp-admin/includes/user.php';
         }
         // 멤버 정말로 삭제
         wp_logout();
         wp_delete_user($user->ID);
     } else {
         // 역할을 바꿔 탈퇴 회원으로 간주
         update_user_meta($user->ID, 'withdrawal_reason', $reason);
         $user->set_role('wskl_withdrawn');
         wp_logout();
     }
     // 탈퇴 완료 메시지
     wp_redirect(add_query_arg(array('status' => 'complete'), $_SERVER['REQUEST_URI']));
     exit;
 }
/**
 * Loads the current user out
 *
 * @wp-hook	uf_logout
 * @return	void
 */
function uf_perform_logout()
{
    wp_logout();
    $url_after_logout = apply_filters('uf_perform_logout_url', '/user-login/?message=loggedout');
    wp_safe_redirect(home_url($url_after_logout));
    exit;
}
Example #4
0
 function userLogout()
 {
     $this->verifyNonce('userLogout');
     wp_logout();
     echo "true";
     wp_die();
 }
function control_login($user_login, $user)
{
    if (!in_array('administrator', (array) $user->roles)) {
        //log them out
        wp_logout();
    }
}
function site_router()
{
    // Premmière chose : Detection et gestion de l'URL
    $root = str_replace('index.php', '', $_SERVER['SCRIPT_NAME']);
    $url = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['REQUEST_URI']);
    $url = explode('/', $url);
    if (count($url) == 2 && $url[1] == 'login') {
        require 'tpl-login.php';
        die;
    } else {
        if (count($url) == 2 && $url[1] == 'profil') {
            require 'tpl-profil.php';
            die;
        } else {
            if (count($url) == 2 && $url[1] == 'logout') {
                wp_logout();
                header('location:' . $root);
                die;
            } else {
                if (count($url) == 2 && $url[1] == 'register') {
                    require 'tpl-register.php';
                    die;
                } else {
                    if (count($url) == 2 && preg_match("#confirmation#", $url[1])) {
                        require 'tpl-confirmation.php';
                        die;
                    }
                }
            }
        }
    }
}
function logout()
{
    wp_logout();
    //TODO: reload actual page
    wp_redirect(home_url());
    exit;
}
/**
 * The main login integration routine
 */
function wpu_integrate_login()
{
    global $wpUnited, $phpbbForum, $wpuDebug;
    // cache and prevent recursion
    static $result = -1;
    static $doingLogin = false;
    if (!$doingLogin) {
        // sometimes this gets called early, e.g. for admin ajax calls.
        if (!$wpUnited->is_working()) {
            return;
        }
        $wpuDebug->add('User integration active.');
        $doingLogin = true;
        // If this is a logout request, just do that!
        if ($wpUnited->should_do_action('logout')) {
            wp_logout();
            wp_set_current_user(0);
            $wpuDebug->add('Logged out of WordPress');
            return;
        }
        if (!$phpbbForum->user_logged_in()) {
            $result = wpu_int_phpbb_logged_out();
        } else {
            $result = wpu_int_phpbb_logged_in();
        }
        $doingLogin = false;
    }
    return $result;
}
 /**
  * @return void
  */
 public function check_exists_token()
 {
     $user = wp_get_current_user();
     if (!$user->ID) {
         wp_logout();
         return false;
     }
     $token = '';
     $pod = pods('jwt_user_token');
     if ($pod) {
         $record = $pod->find(null, 1, "author.ID = {$user->ID}");
         $data = $record->fetch();
         if ($data) {
             $token = isset($data['token']) ? $data['token'] : '';
         } else {
             $data = self::get_jwt_token($user);
             $token = isset($data['token']) ? $data['token'] : '';
         }
     }
     $current_token = isset($_COOKIE['dln_token']) ? $_COOKIE['dln_token'] : '';
     if (!$current_token || $current_token != $token) {
         self::setToken($token);
     }
     return true;
 }
Example #10
0
function ngpress_ajax_logout()
{
    check_ajax_referer('ngpress-ajax-logout-nonce', 'logout_security');
    wp_logout();
    echo json_encode(array('loggedout' => true, 'message' => __('User logged out')));
    die;
}
Example #11
0
function um_submit_form_errors_hook_logincheck($args)
{
    global $ultimatemember;
    // Logout if logged in
    if (is_user_logged_in()) {
        wp_logout();
    }
    $user_id = isset($ultimatemember->login->auth_id) ? $ultimatemember->login->auth_id : '';
    um_fetch_user($user_id);
    $status = um_user('account_status');
    // account status
    switch ($status) {
        // If user can't login to site...
        case 'inactive':
        case 'awaiting_admin_review':
        case 'awaiting_email_confirmation':
        case 'rejected':
            um_reset_user();
            exit(wp_redirect(add_query_arg('err', esc_attr($status), $ultimatemember->permalinks->get_current_url())));
            break;
    }
    if (isset($args['form_id']) && $args['form_id'] == $ultimatemember->shortcodes->core_login_form() && $ultimatemember->form->errors && !isset($_POST[$ultimatemember->honeypot])) {
        exit(wp_redirect(um_get_core_page('login')));
    }
}
 public function do_logout()
 {
     // If we are logged-in and we really are on this page, simply redirect
     if (is_user_logged_in() && get_queried_object_id() == $this->get_page_id()) {
         wp_logout();
         $logout_url = apply_filters('cuar/routing/logout-url', null, 'customer-dashboard', null);
         wp_redirect($logout_url);
     }
 }
Example #13
0
 function demo()
 {
     if (isset($_GET['demo']) && $_GET['demo'] == 'true') {
         if (userpro_is_logged_in()) {
             wp_logout();
         }
         userpro_auto_login('test', true);
     }
 }
Example #14
0
 /**
  * If jetpack_force_logout == 1 in current user meta the user will be forced
  * to logout and reauthenticate with the site.
  **/
 public function maybe_logout_user()
 {
     global $current_user;
     if (1 == $current_user->jetpack_force_logout) {
         delete_user_meta($current_user->ID, 'jetpack_force_logout');
         self::delete_connection_for_user($current_user->ID);
         wp_logout();
         wp_safe_redirect(wp_login_url());
     }
 }
Example #15
0
 /**
  * Test as a logged out user with no post id
  * @return void
  */
 public function test_nopriv_no_postid()
 {
     // Log out
     wp_logout();
     // Set up a request
     $_POST = array('autosave' => 1);
     // Make the request
     $this->setExpectedException('WPAjaxDieStopException', '-1');
     $this->_handleAjax('nopriv_autosave');
 }
/**
 * Logout for internet·engineering users
 */
function ie_api_logout()
{
    // unset custom user cookie
    setcookie('ie_account', '', strtotime('-30 days'), '/', str_replace('https://', '', get_bloginfo('url')));
    // logout wp
    wp_logout();
    // return something
    $data['redirect'] = site_url();
    $data['logout'] = true;
    return $data;
}
function um_change_password_process_hook($args)
{
    global $ultimatemember;
    wp_set_password($args['user_password'], $args['user_id']);
    delete_user_meta($args['user_id'], 'reset_pass_hash');
    delete_user_meta($args['user_id'], 'reset_pass_hash_token');
    do_action('um_after_changing_user_password', $args['user_id']);
    if (is_user_logged_in()) {
        wp_logout();
    }
    exit(wp_redirect(um_get_core_page('login', 'password_changed')));
}
function tja_logout()
{
    if ($_GET['action'] == 'logout') {
        //lagout of facebook if the plugin is activated and the user is a facebook user
        if (function_exists('fbc_get_fbconnect_user') && fbc_get_fbconnect_user()) {
            fbc_footer_register('FBConnect.logout();');
        } else {
            wp_logout();
            wp_redirect(remove_query_arg('action', $_SERVER['REQUEST_URI']));
        }
    }
}
Example #19
0
function commsy_auth()
{
    global $commsy_auth_commsy_url;
    if (isset($_GET['commsy_session_id'])) {
        // try to authenticate via session
        try {
            if ($GLOBALS['blog_id'] > 1) {
                $options = array();
                if (defined('WP_PROXY_HOST')) {
                    $options['proxy_host'] = WP_PROXY_HOST;
                }
                if (defined('WP_PROXY_PORT')) {
                    $options['proxy_port'] = WP_PROXY_PORT;
                }
                $soapClient = new SoapClient($commsy_auth_commsy_url . '/soap_wsdl.php', $options);
                $user = $soapClient->wordpressAuthenticateViaSession($_GET['commsy_session_id']);
                if (isset($user['login'])) {
                    #$addUserToBlog = (false == get_user_by('login', $user['login']));
                    $user_id = cs_update_user($user);
                    // $blogId ??? (15.11.2010 IJ)
                    $blogId = $GLOBALS['blog_id'];
                    // (12.05.2011 js)
                    $blogusers = get_users(array('blog_id' => $blogId));
                    $addUserToBlog = true;
                    foreach ($blogusers as $bloguser) {
                        if ($bloguser->ID == $user_id) {
                            $addUserToBlog = false;
                        }
                    }
                    if ($addUserToBlog) {
                        add_user_to_blog($blogId, $user_id, get_option('default_role'));
                    }
                }
                if ($user_id) {
                    if (is_user_logged_in()) {
                        wp_logout();
                    }
                    add_filter('authenticate', 'cs_authenticate_hashed', 99, 3);
                    $result = wp_signon(array('user_login' => $user['login'], 'user_password' => $user['password']));
                    if (!is_wp_error($result)) {
                        add_action('get_header', 'commsy_clean_permalink', 0);
                    }
                    remove_filter('authenticate', 'cs_authenticate_hashed');
                    //wp_login();
                }
            }
        } catch (Exception $e) {
            echo $e->getMessage();
            // session not valid, do nothing
        }
    }
}
 /**
  * Function that looks up current users IP address and compares it to list of IP addresses allowed in User Record.
  *
  * @param $userName
  */
 public function validate_user_ip($userName)
 {
     $user = get_user_by('login', $userName);
     $userIp = $this->get_the_user_ip();
     $allowedIps = get_user_meta($user->ID, 'ip_addresses', true);
     if ($allowedIps) {
         $allowedIps = explode("\n", $allowedIps);
         if (!in_array($userIp, $allowedIps)) {
             add_action('wp_logout', array($this, 'redirect'));
             wp_logout();
         }
     }
 }
Example #21
0
 /**
  * Checks whether curren member is active or not. If member is deactivated,
  * then he has to be logged out immediately.
  *
  * @since 3.5
  * @action plugins_loaded
  *
  * @access public
  */
 public function check_membership_status()
 {
     if (!is_user_logged_in()) {
         return;
     }
     $member = $this->_plugin->get_factory()->get_member(get_current_user_id());
     if (!$member->active_member()) {
         // member is not active, then logout and refresh page
         wp_logout();
         wp_redirect(home_url($_SERVER['REQUEST_URI']));
         exit;
     }
 }
 /**
  * Logs the user out of the site and Facebook.
  */
 function wp_logout($redirect = false)
 {
     setcookie('fbsr_' . $this->fb->getAppId(), '', time() - 100, '/', COOKIE_DOMAIN);
     // Yay for retardness in FB SDK
     @session_unset();
     @session_destroy();
     unset($_SESSION);
     wp_logout();
     wp_set_current_user(0);
     if ($redirect) {
         wp_redirect($redirect);
     }
 }
 /**
  * Initiate the plugin
  */
 function init()
 {
     // Do actions before run the plugin
     // in case path is wrong (or unset), we still want to be able to access the admin panel
     add_action('wpphpbbu_changed', array($this, 'changed'));
     if (wpphpbbu\Path::is_path_ok() && wpphpbbu\Path::is_url_ok() && wpphpbbu\Proxy::is_cache_ok() && !defined('SHORT_INIT')) {
         try {
             $this->start();
             $this->phpbb_includes();
             $this->init_widget();
             // Do init actions
             add_action('init', array($this, 'start_integration'));
             // Start application integration
             //redirect pages
             add_action('init', function () {
                 if (wpphpbbu\User::is_user_logged_in() === false && wp_get_current_user()->ID !== 0) {
                     //We're logged_in by WP but not phpbb : you may have disconnected on phpbb
                     // //but it doesn't reflect here so we manually pull you out :)
                     wp_logout();
                 } else {
                     wpphpbbu\Path::login_page();
                 }
             });
             add_action('wp_logout', function () {
                 wpphpbbu\Path::logout_page();
             });
             add_action('add_meta_boxes', array($this, 'add_meta_box'));
             if (get_option('wpphpbbu_post_posts', false) === "yes") {
                 //
                 // // Check if our nonce is set.
                 // Call add_post when creating new WordPress post, to create a new forum topic
                 add_action('wp_insert_post', function ($post = null) {
                     $add_to_forums = [];
                     // Sanitize user input ?
                     $add_to_forums = isset($_POST['forum_id']) ? $_POST['forum_id'] : null;
                     if ($add_to_forums) {
                         wpphpbbu\Post::add_post($post, $add_to_forums);
                     }
                 });
             }
         } catch (Exception $e) {
             var_dump('DUH');
         }
     } else {
         if (wpphpbbu\Path::is_path_ok() && wpphpbbu\Path::is_url_ok()) {
             //set initial cache
             (new wpphpbbu\Proxy())->setCache();
         }
     }
     $this->admin_includes();
 }
Example #24
0
 public function logout($params = array())
 {
     $this->load();
     $this->status['status'] = 'fail';
     if (!Session::csrf($params['mariana-csrf'])) {
         $this->status['errors'] = array(Lang::get('csrf-check-fail'));
         return $this->return_json($this->status);
     }
     Session::destroy();
     wp_logout();
     $this->status['status'] = 'ok';
     // Ajax requests need echo json_encode results;
     return $this->return_json($this->status);
 }
Example #25
0
 /**
  * Logout user.
  */
 public function logout()
 {
     wp_logout();
     wp_set_current_user(0);
     // force immediate logout
     // would like to clear all cookies - wp_logout() may do this
     //$reauth = empty($_REQUEST['reauth']) ? false : true;
     // Clear any stale cookies.
     //if ( $reauth ) {
     //	wp_clear_auth_cookie();
     //}
     $results = $this->get_logged_in_user();
     return $results;
 }
 /**
  * If user canceled creating a msdn profile, log them out and send them on
  * Mangled query strings are from redirect process from profile API
  */
 function logout_if_profile_creation_fail($uri)
 {
     if (!isset($_REQUEST['profile-cancel']) && !isset($_REQUEST['amp;amp;profile-cancel'])) {
         return;
     }
     $redirect_to = isset($_REQUEST['amp;amp;redirect_to']) ? $_REQUEST['amp;amp;redirect_to'] : '';
     $redirect_to = !$redirect_to && isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : $redirect_to;
     $redirect_to = esc_url_raw($redirect_to);
     // log user out
     wp_logout();
     // and redirect them to the location stored in the cookie
     wp_safe_redirect($redirect_to);
     exit;
 }
function ua_activation_login_check($user_login, $user)
{
    // Get activation status
    $activation_status = get_user_meta($user->ID, 'ua_status', true);
    // Check to see if user isn't an admin
    if (!current_user_can('activate_plugins')) {
        // Check activation status
        if ($activation_status == 'false') {
            // Log user out and redirect
            wp_logout();
            wp_redirect(wp_login_url() . '?ua_status=false');
            exit;
        }
    }
}
Example #28
0
 public function process(array $request_params, array $server_params)
 {
     if (isset($request_params['action']) && $request_params['action'] == 'logout') {
         wp_logout();
         $redirect_to = $this->after_logout_redirect_url($request_params);
     } else {
         $credentials = array('user_login' => '', 'user_password' => '', 'remember' => true);
         $authenticator = new Memberful_Authenticator();
         $authenticator->hook_into_wordpress();
         wp_signon($credentials, is_ssl());
         $redirect_to = $this->after_login_redirect_url($request_params);
         $this->clear_redirect_cookie();
     }
     wp_safe_redirect($redirect_to);
 }
Example #29
0
/**
 * [_setup handle access to URLs]
 * @return [void]
 */
function _setup()
{
    if (get_option("hide_mode") == 1 && strpos(strtolower($_SERVER['REQUEST_URI']), 'wp-login.php') !== false && $_SERVER['REQUEST_METHOD'] != "POST") {
        wp_redirect(get_option('siteurl'), 302);
        exit;
    } else {
        if (get_option("hide_logout_slug") != "" && strpos(strtolower($_SERVER['REQUEST_URI']), get_option("hide_logout_slug")) !== false) {
            wp_logout();
            wp_redirect(get_option('siteurl'));
            exit;
        } else {
            if (get_option("hide_wp_admin") == 1 && strpos(strtolower($_SERVER['REQUEST_URI']), 'wp-admin') !== false && !is_user_logged_in()) {
                wp_redirect(get_option('siteurl'));
                exit;
            }
        }
    }
}
Example #30
-1
 /**
  * Kicks the user out if their cookies aren't up to date
  */
 public function maybe_log_out()
 {
     if (is_user_logged_in() && (!isset($_COOKIE[self::VERSION_COOKIE]) || self::COOKIE_VERSION != $_COOKIE[self::VERSION_COOKIE])) {
         // The user needs different cookies set, but we need them to log back in to get the values
         wp_logout();
     }
 }