当前位置: 首页>>代码示例>>PHP>>正文


PHP get_active_blog_for_user函数代码示例

本文整理汇总了PHP中get_active_blog_for_user函数的典型用法代码示例。如果您正苦于以下问题:PHP get_active_blog_for_user函数的具体用法?PHP get_active_blog_for_user怎么用?PHP get_active_blog_for_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_active_blog_for_user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: initialize

 public function initialize()
 {
     $this->user = new stdClass();
     if (is_user_logged_in()) {
         /* Populate settings we need for the menu based on the current user. */
         $this->user->blogs = get_blogs_of_user(get_current_user_id());
         if (is_multisite()) {
             $this->user->active_blog = get_active_blog_for_user(get_current_user_id());
             $this->user->domain = empty($this->user->active_blog) ? user_admin_url() : trailingslashit(get_home_url($this->user->active_blog->blog_id));
             $this->user->account_domain = $this->user->domain;
         } else {
             $this->user->active_blog = $this->user->blogs[get_current_blog_id()];
             $this->user->domain = trailingslashit(home_url());
             $this->user->account_domain = $this->user->domain;
         }
     }
     add_action('wp_head', 'wp_admin_bar_header');
     add_action('admin_head', 'wp_admin_bar_header');
     if (current_theme_supports('admin-bar')) {
         $admin_bar_args = get_theme_support('admin-bar');
         // add_theme_support( 'admin-bar', array( 'callback' => '__return_false') );
         $header_callback = $admin_bar_args[0]['callback'];
     }
     if (empty($header_callback)) {
         $header_callback = '_admin_bar_bump_cb';
     }
     add_action('wp_head', $header_callback);
     wp_enqueue_script('admin-bar');
     wp_enqueue_style('admin-bar');
     do_action('admin_bar_init');
 }
开发者ID:rmccue,项目名称:wordpress-unit-tests,代码行数:31,代码来源:class-wp-admin-bar.php

示例2: test_get_active_blog_for_user_with_spam_site

 /**
  * @ticket 38355
  */
 public function test_get_active_blog_for_user_with_spam_site()
 {
     $current_site_id = get_current_blog_id();
     $site_id = self::factory()->blog->create(array('user_id' => self::$user_id, 'meta' => array('spam' => 1)));
     add_user_to_blog($site_id, self::$user_id, 'subscriber');
     update_user_meta(self::$user_id, 'primary_blog', $site_id);
     $result = get_active_blog_for_user(self::$user_id);
     wpmu_delete_blog($site_id, true);
     $this->assertEquals($current_site_id, $result->id);
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:13,代码来源:getActiveBlogForUser.php

示例3: thatcamp_edit_profile_url

function thatcamp_edit_profile_url($url)
{
    $path = 'profile.php';
    $scheme = 'admin';
    $active = get_active_blog_for_user(get_current_user_id());
    if ($active) {
        $url = get_admin_url($active->blog_id, $path, $scheme);
    } else {
        $url = user_admin_url($path, $scheme);
    }
    return $url;
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:12,代码来源:thatcamp-setup-admin-page.php

示例4: initialize

	/**
	 * @access public
	 */
	public function initialize() {
		$this->user = new stdClass;

		if ( is_user_logged_in() ) {
			/* Populate settings we need for the menu based on the current user. */
			$this->user->blogs = get_blogs_of_user( get_current_user_id() );
			if ( is_multisite() ) {
				$this->user->active_blog = get_active_blog_for_user( get_current_user_id() );
				$this->user->domain = empty( $this->user->active_blog ) ? user_admin_url() : trailingslashit( get_home_url( $this->user->active_blog->blog_id ) );
				$this->user->account_domain = $this->user->domain;
			} else {
				$this->user->active_blog = $this->user->blogs[get_current_blog_id()];
				$this->user->domain = trailingslashit( home_url() );
				$this->user->account_domain = $this->user->domain;
			}
		}

		add_action( 'wp_head', 'wp_admin_bar_header' );

		add_action( 'admin_head', 'wp_admin_bar_header' );

		if ( current_theme_supports( 'admin-bar' ) ) {
			/**
			 * To remove the default padding styles from WordPress for the Toolbar, use the following code:
			 * add_theme_support( 'admin-bar', array( 'callback' => '__return_false' ) );
			 */
			$admin_bar_args = get_theme_support( 'admin-bar' );
			$header_callback = $admin_bar_args[0]['callback'];
		}

		if ( empty($header_callback) )
			$header_callback = '_admin_bar_bump_cb';

		add_action('wp_head', $header_callback);

		wp_enqueue_script( 'admin-bar' );
		wp_enqueue_style( 'admin-bar' );

		/**
		 * Fires after WP_Admin_Bar is initialized.
		 *
		 * @since 3.1.0
		 */
		do_action( 'admin_bar_init' );
	}
开发者ID:ShankarVellal,项目名称:WordPress,代码行数:48,代码来源:class-wp-admin-bar.php

示例5: wpmu_subscribe

 /**
 Handles subscriptions and unsubscriptions for different blogs on WPMU installs
 */
 function wpmu_subscribe()
 {
     global $mysubscribe2;
     // subscribe to new blog
     if (!empty($_GET['s2mu_subscribe'])) {
         $sub_id = intval($_GET['s2mu_subscribe']);
         if ($sub_id >= 0) {
             switch_to_blog($sub_id);
             $user_ID = get_current_user_id();
             // if user is not a user of the current blog
             if (!is_blog_user($sub_id)) {
                 // add user to current blog as subscriber
                 add_user_to_blog($sub_id, $user_ID, 'subscriber');
                 // add an action hook for external manipulation of blog and user data
                 do_action_ref_array('subscribe2_wpmu_subscribe', array($user_ID, $sub_id));
             }
             // get categories, remove excluded ones if override is off
             if (0 == $mysubscribe2->subscribe2_options['reg_override']) {
                 $all_cats = $mysubscribe2->all_cats(true, 'ID');
             } else {
                 $all_cats = $mysubscribe2->all_cats(false, 'ID');
             }
             $cats_string = '';
             foreach ($all_cats as $cat) {
                 '' == $cats_string ? $cats_string = "{$cat->term_id}" : ($cats_string .= ",{$cat->term_id}");
                 update_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_cat') . $cat->term_id, $cat->term_id);
             }
             if (empty($cats_string)) {
                 delete_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'));
             } else {
                 update_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'), $cats_string);
             }
         }
     } elseif (!empty($_GET['s2mu_unsubscribe'])) {
         // unsubscribe from a blog
         $unsub_id = intval($_GET['s2mu_unsubscribe']);
         if ($unsub_id >= 0) {
             switch_to_blog($unsub_id);
             $user_ID = get_current_user_id();
             // delete subscription to all categories on that blog
             $cats = get_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'), true);
             $cats = explode(',', $cats);
             if (!is_array($cats)) {
                 $cats = array($cats);
             }
             foreach ($cats as $id) {
                 delete_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_cat') . $id);
             }
             delete_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'));
             // add an action hook for external manipulation of blog and user data
             do_action_ref_array('subscribe2_wpmu_unsubscribe', array($user_ID, $unsub_id));
             restore_current_blog();
         }
     }
     if (!is_user_member_of_blog($user_ID)) {
         $user_blogs = get_active_blog_for_user($user_ID);
         if (is_array($user_blogs)) {
             switch_to_blog(key($user_blogs));
         } else {
             // no longer a member of a blog
             wp_redirect(get_option('siteurl'));
             // redirect to front page
             exit(0);
         }
     }
     // redirect to profile page
     $url = get_option('siteurl') . '/wp-admin/admin.php?page=s2';
     wp_redirect($url);
     exit(0);
 }
开发者ID:juslee,项目名称:e27,代码行数:73,代码来源:class-s2_multisite.php

示例6: get_author

 public function get_author()
 {
     if (0 == $this->post->post_author) {
         return null;
     }
     $show_email = $this->context === 'edit' && current_user_can('edit_post', $this->post);
     $user = get_user_by('id', $this->post->post_author);
     if (!$user || is_wp_error($user)) {
         trigger_error('Unknown user', E_USER_WARNING);
         return null;
     }
     // TODO factor this out
     if (defined('IS_WPCOM') && IS_WPCOM) {
         $active_blog = get_active_blog_for_user($user->ID);
         $site_id = $active_blog->blog_id;
         $profile_URL = "http://en.gravatar.com/{$user->user_login}";
     } else {
         $profile_URL = 'http://en.gravatar.com/' . md5(strtolower(trim($user->user_email)));
         $site_id = -1;
     }
     $author = array('ID' => (int) $user->ID, 'login' => (string) $user->user_login, 'email' => $show_email ? (string) $user->user_email : false, 'name' => (string) $user->display_name, 'first_name' => (string) $user->first_name, 'last_name' => (string) $user->last_name, 'nice_name' => (string) $user->user_nicename, 'URL' => (string) esc_url_raw($user->user_url), 'avatar_URL' => (string) esc_url_raw($this->get_avatar_url($user->user_email)), 'profile_URL' => (string) esc_url_raw($profile_URL));
     if ($site_id > -1) {
         $author['site_ID'] = (int) $site_id;
     }
     return (object) $author;
 }
开发者ID:elliott-stocks,项目名称:jetpack,代码行数:26,代码来源:class.json-api-post-base.php

示例7: function

                if ($customize_login) {
                    ?>
				<script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php 
                    echo wp_customize_url();
                    ?>
', channel: 'login' }).send('login') }, 1000 );</script>
			<?php 
                }
                ?>
			</body></html>
<?php 
                exit;
            }
            if (empty($redirect_to) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url()) {
                // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile.
                if (is_multisite() && !get_active_blog_for_user($user->ID) && !is_super_admin($user->ID)) {
                    $redirect_to = user_admin_url();
                } elseif (is_multisite() && !$user->has_cap('read')) {
                    $redirect_to = get_dashboard_url($user->ID);
                } elseif (!$user->has_cap('edit_posts')) {
                    $redirect_to = $user->has_cap('read') ? admin_url('profile.php') : home_url();
                }
            }
            wp_safe_redirect($redirect_to);
            exit;
        }
        $errors = $user;
        // Clear errors if loggedout is set.
        if (!empty($_GET['loggedout']) || $reauth) {
            $errors = new WP_Error();
        }
开发者ID:neruub,项目名称:shop_sda,代码行数:31,代码来源:wp-login.php

示例8: login

 /**
  * Login user. SSL support is not tested. 
  */
 public function login()
 {
     global $json_api;
     $secure_cookie = '';
     // If the user wants ssl but the session is not ssl, force a secure cookie.
     if (!empty($_POST['log']) && !force_ssl_admin()) {
         $user_name = sanitize_user($_POST['log']);
         if ($user = get_user_by('login', $user_name)) {
             // i'm guessing the user can change their login options to work with SSL
             if (get_user_option('use_ssl', $user->ID)) {
                 $secure_cookie = true;
                 //passing true to like so, force_ssl_admin(true), makes force_ssl_admin() return true and vice versa
                 //force_ssl_admin(true); http://codex.wordpress.org/Function_Reference/force_ssl_admin
                 // we are declaring error but not returning it for now
                 $errors = new WP_Error();
                 $errors->add('use_ssl', __("The login must use ssl."));
                 // not implemeted now
                 //return $errors;
             }
         }
     }
     if (isset($_REQUEST['redirect_to'])) {
         $redirect_to = $_REQUEST['redirect_to'];
         // Redirect to https if user wants ssl
         if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin')) {
             $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
         }
     } else {
         $redirect_to = admin_url();
     }
     $reauth = empty($_REQUEST['reauth']) ? false : true;
     // If the user was redirected to a secure login form from a non-secure admin page, and secure login is required but secure admin is not, then don't use a secure
     // cookie and redirect back to the referring non-secure admin page.  This allows logins to always be POSTed over SSL while allowing the user to choose visiting
     // the admin via http or https.
     if (!$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && 0 !== strpos($redirect_to, 'https') && 0 === strpos($redirect_to, 'http')) {
         $secure_cookie = false;
     }
     //$user = wp_authenticate_username_password('', $_POST['log'], $_POST['pwd']);
     $user = wp_signon('', $secure_cookie);
     if (is_wp_error($user)) {
         // user is an error object
         $errors = $user;
         // if both login and password are empty no error is added so we add one now
         if (empty($_POST['log']) && empty($_POST['pwd'])) {
             $errors->add('invalid_username', __("The username is empty."));
         }
         // Clear errors if loggedout is set.
         if (!empty($_GET['loggedout']) || $reauth) {
             $errors = new WP_Error();
         }
         // If cookies are disabled we can't log in even with a valid user+pass
         if (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE])) {
             $errors->add('test_cookie', __("Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress."));
         }
         // Some parts of this script use the main login form to display a message
         if (isset($_GET['loggedout']) && TRUE == $_GET['loggedout']) {
             $errors->add('loggedout', __('You are now logged out.'), 'message');
         } elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) {
             $errors->add('registerdisabled', __('User registration is currently not allowed.'));
         } elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) {
             $errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message');
         } elseif (isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail']) {
             $errors->add('newpass', __('Check your e-mail for your new password.'), 'message');
         } elseif (isset($_GET['checkemail']) && 'registered' == $_GET['checkemail']) {
             $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message');
         } elseif ($interim_login) {
             $errors->add('expired', __('Your session has expired. Please log-in again.'), 'message');
         }
         // Clear any stale cookies.
         if ($reauth) {
             wp_clear_auth_cookie();
         }
         return $errors;
     }
     //if (!$reauth) {
     // does not redirect
     if (empty($redirect_to) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url()) {
         // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile.
         if (is_multisite() && !get_active_blog_for_user($user->ID) && !is_super_admin($user->ID)) {
             $redirect_to = user_admin_url();
         } elseif (is_multisite() && !$user->has_cap('read')) {
             $redirect_to = get_dashboard_url($user->ID);
         } elseif (!$user->has_cap('edit_posts')) {
             $redirect_to = admin_url('profile.php');
         }
     }
     wp_set_current_user($user->ID);
     $user = $this->get_logged_in_user();
     // left in redirect_to since we could return the value later if we wanted
     return $user;
     //}
 }
开发者ID:andreiRS,项目名称:Radii8,代码行数:95,代码来源:user.php

示例9: test_admin_bar_contains_correct_links_for_users_with_no_role_on_network

 /**
  * @ticket 25162
  * @group multisite
  */
 public function test_admin_bar_contains_correct_links_for_users_with_no_role_on_network()
 {
     if (!is_multisite()) {
         $this->markTestSkipped('Test only runs in multisite');
     }
     $this->assertTrue(user_can(self::$admin_id, 'read'));
     $this->assertFalse(user_can(self::$no_role_id, 'read'));
     $blog_id = self::factory()->blog->create(array('user_id' => self::$admin_id));
     $this->assertTrue(is_user_member_of_blog(self::$admin_id, $blog_id));
     $this->assertFalse(is_user_member_of_blog(self::$no_role_id, $blog_id));
     $this->assertTrue(is_user_member_of_blog(self::$no_role_id, get_current_blog_id()));
     // Remove `$nobody` from the current blog, so they're not a member of any blog
     $removed = remove_user_from_blog(self::$no_role_id, get_current_blog_id());
     $this->assertTrue($removed);
     $this->assertFalse(is_user_member_of_blog(self::$no_role_id, get_current_blog_id()));
     wp_set_current_user(self::$no_role_id);
     switch_to_blog($blog_id);
     $wp_admin_bar = $this->get_standard_admin_bar();
     $node_site_name = $wp_admin_bar->get_node('site-name');
     $node_my_account = $wp_admin_bar->get_node('my-account');
     $node_user_info = $wp_admin_bar->get_node('user-info');
     $node_edit_profile = $wp_admin_bar->get_node('edit-profile');
     // get primary blog
     $primary = get_active_blog_for_user(self::$no_role_id);
     $this->assertNull($primary);
     // No Site menu as the user isn't a member of this site
     $this->assertNull($node_site_name);
     $user_profile_url = user_admin_url('profile.php');
     $this->assertNotEquals($user_profile_url, admin_url('profile.php'));
     // Profile URLs should go to the user's primary blog
     $this->assertEquals($user_profile_url, $node_my_account->href);
     $this->assertEquals($user_profile_url, $node_user_info->href);
     $this->assertEquals($user_profile_url, $node_edit_profile->href);
     restore_current_blog();
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:39,代码来源:adminbar.php

示例10: redirect_user_to_blog

function redirect_user_to_blog()
{
    global $current_user;
    $c = 0;
    if (isset($_GET['c'])) {
        $c = (int) $_GET['c'];
    }
    if ($c >= 5) {
        wp_die(__("You don&#8217;t have permission to view this site. Please contact the system administrator."));
    }
    $c++;
    $blog = get_active_blog_for_user($current_user->ID);
    $dashboard_blog = get_dashboard_blog();
    if (is_object($blog)) {
        wp_redirect(get_admin_url($blog->blog_id, '?c=' . $c));
        // redirect and count to 5, "just in case"
        exit;
    }
    /*
      If the user is a member of only 1 blog and the user's primary_blog isn't set to that blog,
      then update the primary_blog record to match the user's blog
    */
    $blogs = get_blogs_of_user($current_user->ID);
    if (!empty($blogs)) {
        foreach ($blogs as $blogid => $blog) {
            if ($blogid != $dashboard_blog->blog_id && get_user_meta($current_user->ID, 'primary_blog', true) == $dashboard_blog->blog_id) {
                update_user_meta($current_user->ID, 'primary_blog', $blogid);
                continue;
            }
        }
        $blog = get_blog_details(get_user_meta($current_user->ID, 'primary_blog', true));
        wp_redirect(get_admin_url($blog->blog_id, '?c=' . $c));
        exit;
    }
    wp_die(__('You do not have sufficient permissions to access this page.'));
}
开发者ID:owaismeo,项目名称:wordpress-10,代码行数:36,代码来源:ms.php

示例11: __

                $message = '<p class="message">' . __('You have logged in successfully.') . '</p>';
                login_header('', $message);
                ?>
			<script type="text/javascript">setTimeout( function(){window.close()}, 8000);</script>
			<p class="alignright">
			<input type="button" class="btn" value="<?php 
                esc_attr_e('Close');
                ?>
" onclick="window.close()" /></p>
			</div></body></html>
<?php 
                exit;
            }
            if (empty($redirect_to) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url()) {
                // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile.
                if (is_multisite() && !get_active_blog_for_user($user->id)) {
                    $redirect_to = user_admin_url();
                } elseif (is_multisite() && !$user->has_cap('read')) {
                    $redirect_to = get_dashboard_url($user->id);
                } elseif (!$user->has_cap('edit_posts')) {
                    $redirect_to = admin_url('profile.php');
                }
            }
            wp_safe_redirect($redirect_to);
            exit;
        }
        $errors = $user;
        // Clear errors if loggedout is set.
        if (!empty($_GET['loggedout']) || $reauth) {
            $errors = new WP_Error();
        }
开发者ID:ashray-velapanur,项目名称:grind-members,代码行数:31,代码来源:wp-login.php

示例12: simplr_login_includes

function simplr_login_includes($post, $option, $file, $path)
{
    global $errors, $is_iphone, $interim_login, $current_site;
    $http_post = 'POST' == $_SERVER['REQUEST_METHOD'];
    $options = get_option('simplr_reg_options');
    global $wp;
    $action = @$_REQUEST['action'];
    if (@$_REQUEST['action'] == '') {
        wp_redirect('?action=login');
    }
    if (isset($options->login_redirect) and end($path) == $post->post_name) {
        switch ($action) {
            case 'lostpassword':
            case 'retrievepassword':
                if (isset($http_post)) {
                    $errors = retrieve_password();
                    if (!is_wp_error($errors)) {
                        $redirect_to = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm';
                        wp_safe_redirect($redirect_to);
                        exit;
                    }
                }
                if (isset($_GET['error']) && 'invalidkey' == $_GET['error']) {
                    $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.', 'simplr-registration-form'));
                }
                $redirect_to = apply_filters('lostpassword_redirect', !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '');
                do_action('lost_password');
                $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : '';
                break;
            case 'login':
            case 'default':
                $secure_cookie = '';
                $interim_login = isset($_REQUEST['interim-login']);
                // If the user wants ssl but the session is not ssl, force a secure cookie.
                if (!empty($_POST['log']) && !force_ssl_admin()) {
                    $user_name = sanitize_user($_POST['log']);
                    if ($user = get_userdatabylogin($user_name)) {
                        if (get_user_option('use_ssl', $user->ID)) {
                            $secure_cookie = true;
                            force_ssl_admin(true);
                        }
                    }
                }
                if (isset($_REQUEST['redirect_to'])) {
                    $redirect_to = $_REQUEST['redirect_to'];
                    // Redirect to https if user wants ssl
                    if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin')) {
                        $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
                    }
                } else {
                    $redirect_to = admin_url();
                }
                $reauth = empty($_REQUEST['reauth']) ? false : true;
                // If the user was redirected to a secure login form from a non-secure admin page, and secure login is required but secure admin is not, then don't use a secure
                // cookie and redirect back to the referring non-secure admin page.  This allows logins to always be POSTed over SSL while allowing the user to choose visiting
                // the admin via http or https.
                if (!$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && 0 !== strpos($redirect_to, 'https') && 0 === strpos($redirect_to, 'http')) {
                    $secure_cookie = false;
                }
                $user = wp_signon('', $secure_cookie);
                $redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user);
                if (!is_wp_error($user) && !$reauth) {
                    if ($interim_login) {
                        $message = '<p class="message">' . __('You have logged in successfully.', 'simplr-registration-form') . '</p>';
                        ?>
						<script type="text/javascript">setTimeout( function(){window.close()}, 8000);</script>
						<p class="alignright">
						<input type="button" class="button-primary" value="<?php 
                        esc_attr_e('Close', 'simplr-registration-form');
                        ?>
" onclick="window.close()" /></p>
						</div></body></html>
				<?php 
                        exit;
                    }
                    if (empty($redirect_to) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url()) {
                        // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile.
                        if (is_multisite() && !get_active_blog_for_user($user->id) && !is_super_admin($user->id)) {
                            $redirect_to = user_admin_url();
                        } elseif (is_multisite() && !$user->has_cap('read')) {
                            $redirect_to = get_dashboard_url($user->id);
                        } elseif (!$user->has_cap('edit_posts')) {
                            $redirect_to = admin_url('profile.php');
                        }
                    }
                    wp_safe_redirect($redirect_to);
                    exit;
                }
                $errors = $user;
                // Clear errors if loggedout is set.
                if (!empty($_GET['loggedout']) || $reauth) {
                    $errors = new WP_Error();
                }
                // If cookies are disabled we can't log in even with a valid user+pass
                if (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE])) {
                    $errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress.", 'simplr-registration-form'));
                }
                // Some parts of this script use the main login form to display a message
                if (isset($_GET['loggedout']) && TRUE == $_GET['loggedout']) {
                    $errors->add('loggedout', __('You are now logged out.', 'simplr-registration-form'), 'message');
//.........这里部分代码省略.........
开发者ID:ashanrupasinghe,项目名称:govforuminstalledlocal,代码行数:101,代码来源:login.php

示例13: template_redirect


//.........这里部分代码省略.........
             case 'register':
                 if (!get_option('users_can_register')) {
                     $redirect_to = site_url('wp-login.php?registration=disabled');
                     wp_redirect($redirect_to);
                     exit;
                 }
                 $user_login = '';
                 $user_email = '';
                 if ($http_post) {
                     $user_login = $_POST['user_login'];
                     $user_email = $_POST['user_email'];
                     $this->errors = self::register_new_user($user_login, $user_email);
                     if (!is_wp_error($this->errors)) {
                         $redirect_to = !empty($_POST['redirect_to']) ? $_POST['redirect_to'] : site_url('wp-login.php?checkemail=registered');
                         wp_safe_redirect($redirect_to);
                         exit;
                     }
                 }
                 break;
             case 'login':
             default:
                 $secure_cookie = '';
                 $interim_login = isset($_REQUEST['interim-login']);
                 // If the user wants ssl but the session is not ssl, force a secure cookie.
                 if (!empty($_POST['log']) && !force_ssl_admin()) {
                     $user_name = sanitize_user($_POST['log']);
                     if ($user = get_user_by('login', $user_name)) {
                         if (get_user_option('use_ssl', $user->ID)) {
                             $secure_cookie = true;
                             force_ssl_admin(true);
                         }
                     }
                 }
                 if (!empty($_REQUEST['redirect_to'])) {
                     $redirect_to = $_REQUEST['redirect_to'];
                     // Redirect to https if user wants ssl
                     if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin')) {
                         $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
                     }
                 } else {
                     $redirect_to = admin_url();
                 }
                 $reauth = empty($_REQUEST['reauth']) ? false : true;
                 // If the user was redirected to a secure login form from a non-secure admin page, and secure login is required but secure admin is not, then don't use a secure
                 // cookie and redirect back to the referring non-secure admin page.  This allows logins to always be POSTed over SSL while allowing the user to choose visiting
                 // the admin via http or https.
                 if (!$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && 0 !== strpos($redirect_to, 'https') && 0 === strpos($redirect_to, 'http')) {
                     $secure_cookie = false;
                 }
                 if ($http_post && isset($_POST['log'])) {
                     $user = wp_signon('', $secure_cookie);
                     $redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user);
                     if (!is_wp_error($user) && !$reauth) {
                         if (empty($redirect_to) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url()) {
                             // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile.
                             if (is_multisite() && !get_active_blog_for_user($user->ID) && !is_super_admin($user->ID)) {
                                 $redirect_to = user_admin_url();
                             } elseif (is_multisite() && !$user->has_cap('read')) {
                                 $redirect_to = get_dashboard_url($user->ID);
                             } elseif (!$user->has_cap('edit_posts')) {
                                 $redirect_to = admin_url('profile.php');
                             }
                         }
                         wp_safe_redirect($redirect_to);
                         exit;
                     }
                     $this->errors = $user;
                 }
                 // Clear errors if loggedout is set.
                 if (!empty($_GET['loggedout']) || $reauth) {
                     $this->errors = new WP_Error();
                 }
                 // Some parts of this script use the main login form to display a message
                 if (isset($_GET['loggedout']) && true == $_GET['loggedout']) {
                     $this->errors->add('loggedout', __('You are now logged out.', 'theme-my-login'), 'message');
                 } elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) {
                     $this->errors->add('registerdisabled', __('User registration is currently not allowed.', 'theme-my-login'));
                 } elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) {
                     $this->errors->add('confirm', __('Check your e-mail for the confirmation link.', 'theme-my-login'), 'message');
                 } elseif (isset($_GET['resetpass']) && 'complete' == $_GET['resetpass']) {
                     $this->errors->add('password_reset', __('Your password has been reset.', 'theme-my-login'), 'message');
                 } elseif (isset($_GET['checkemail']) && 'registered' == $_GET['checkemail']) {
                     $this->errors->add('registered', __('Registration complete. Please check your e-mail.', 'theme-my-login'), 'message');
                 } elseif ($interim_login) {
                     $this->errors->add('expired', __('Your session has expired. Please log-in again.', 'theme-my-login'), 'message');
                 } elseif (strpos($redirect_to, 'about.php?updated')) {
                     $this->errors->add('updated', __('<strong>You have successfully updated WordPress!</strong> Please log back in to experience the awesomeness.', 'theme-my-login'), 'message');
                 } elseif ($reauth) {
                     $this->errors->add('reauth', __('Please log in to continue.', 'theme-my-login'), 'message');
                 }
                 // Clear any stale cookies.
                 if ($reauth) {
                     wp_clear_auth_cookie();
                 }
                 break;
         }
         // end switch
     }
     // endif has_filter()
 }
开发者ID:Kilbourne,项目名称:restart,代码行数:101,代码来源:class-theme-my-login.php

示例14: redirect_user_to_blog

function redirect_user_to_blog()
{
    $c = 0;
    if (isset($_GET['c'])) {
        $c = (int) $_GET['c'];
    }
    if ($c >= 5) {
        wp_die(__("You don&#8217;t have permission to view this site. Please contact the system administrator."));
    }
    $c++;
    $blog = get_active_blog_for_user(get_current_user_id());
    if (is_object($blog)) {
        wp_redirect(get_admin_url($blog->blog_id, '?c=' . $c));
        // redirect and count to 5, "just in case"
    } else {
        wp_redirect(user_admin_url('?c=' . $c));
        // redirect and count to 5, "just in case"
    }
    exit;
}
开发者ID:hiroki-namekawa,项目名称:test-upr,代码行数:20,代码来源:ms.php

示例15: action_login

 /**
  * Login hooks
  */
 function action_login()
 {
     $interim_login = isset($_REQUEST['interim-login']);
     $secure_cookie = '';
     $customize_login = isset($_REQUEST['customize-login']);
     if ($customize_login) {
         wp_enqueue_script('customize-base');
     }
     // If the user wants ssl but the session is not ssl, force a secure cookie.
     if (!empty($_POST['log']) && !force_ssl_admin()) {
         $user_name = sanitize_user($_POST['log']);
         if ($user = get_user_by('login', $user_name)) {
             if (get_user_option('use_ssl', $user->ID)) {
                 $secure_cookie = true;
                 force_ssl_admin(true);
             }
         }
     }
     if (isset($_REQUEST['redirect_to'])) {
         $redirect_to = $_REQUEST['redirect_to'];
         // Redirect to https if user wants ssl
         if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin')) {
             $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
         }
     } else {
         $redirect_to = admin_url();
     }
     $reauth = empty($_REQUEST['reauth']) ? false : true;
     $user = wp_signon('', $secure_cookie);
     if (empty($_COOKIE[LOGGED_IN_COOKIE])) {
         if (headers_sent()) {
             $user = new WP_Error('test_cookie', sprintf(__('<strong>ERROR</strong>: Cookies are blocked due to unexpected output. For help, please see <a href="%1$s">this documentation</a> or try the <a href="%2$s">support forums</a>.', 'colabsthemes'), 'http://codex.wordpress.org/Cookies', 'https://wordpress.org/support/'));
         } elseif (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE])) {
             // If cookies are disabled we can't log in even with a valid user+pass
             $user = new WP_Error('test_cookie', sprintf(__('<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.', 'colabsthemes'), 'http://codex.wordpress.org/Cookies'));
         }
     }
     $requested_redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '';
     /**
      * Filter the login redirect URL.
      *
      * @since 3.0.0
      *
      * @param string           $redirect_to           The redirect destination URL.
      * @param string           $requested_redirect_to The requested redirect destination URL passed as a parameter.
      * @param WP_User|WP_Error $user                  WP_User object if login was successful, WP_Error object otherwise.
      */
     $redirect_to = apply_filters('login_redirect', $redirect_to, $requested_redirect_to, $user);
     if (!is_wp_error($user) && !$reauth) {
         if ($interim_login) {
             $message = '<div class="alert alert-success">' . __('You have logged in successfully.', 'colabsthemes') . '</div>';
             $interim_login = 'success';
             echo $message;
         }
         if (empty($redirect_to) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url()) {
             // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile.
             if (is_multisite() && !get_active_blog_for_user($user->ID) && !is_super_admin($user->ID)) {
                 $redirect_to = user_admin_url();
             } elseif (is_multisite() && !$user->has_cap('read')) {
                 $redirect_to = get_dashboard_url($user->ID);
             } elseif (!$user->has_cap('edit_posts')) {
                 $redirect_to = admin_url('profile.php');
             }
         }
         wp_safe_redirect($redirect_to);
         exit;
     }
     $errors = $user;
     // Clear errors if loggedout is set.
     if (!empty($_GET['loggedout']) || $reauth) {
         $errors = new WP_Error();
     }
     if ($interim_login) {
         if (!$errors->get_error_code()) {
             $errors->add('expired', __('Session expired. Please log in again. You will not move away from this page.', 'colabsthemes'), 'message');
         }
     } else {
         // Some parts of this script use the main login form to display a message
         if (isset($_GET['loggedout']) && true == $_GET['loggedout']) {
             $errors->add('loggedout', __('You are now logged out.', 'colabsthemes'), 'message');
         } elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) {
             $errors->add('registerdisabled', __('User registration is currently not allowed.', 'colabsthemes'));
         } elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) {
             $errors->add('confirm', __('Check your e-mail for the confirmation link.', 'colabsthemes'), 'message');
         } elseif (isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail']) {
             $errors->add('newpass', __('Check your e-mail for your new password.', 'colabsthemes'), 'message');
         } elseif (isset($_GET['checkemail']) && 'registered' == $_GET['checkemail']) {
             $errors->add('registered', __('Registration complete. Please check your e-mail.', 'colabsthemes'), 'message');
         } elseif (strpos($redirect_to, 'about.php?updated')) {
             $errors->add('updated', __('<strong>You have successfully updated WordPress!</strong> Please log back in to see what&#8217;s new.', 'colabsthemes'), 'message');
         }
     }
     /**
      * Filter the login page errors.
      *
      * @since 3.6.0
      *
//.........这里部分代码省略.........
开发者ID:nickwoodland,项目名称:easysitges,代码行数:101,代码来源:theme-login.php


注:本文中的get_active_blog_for_user函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。