本文整理汇总了PHP中get_dashboard_url函数的典型用法代码示例。如果您正苦于以下问题:PHP get_dashboard_url函数的具体用法?PHP get_dashboard_url怎么用?PHP get_dashboard_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_dashboard_url函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: widget
/**
* Outputs the content of the widget
*
* @param array $args
* @param array $instance
*/
public function widget($args, $instance) {
$title = apply_filters('widget_title', $instance['title']);
echo $args['before_widget'];
echo '<div class="event-widget">';
if (is_user_logged_in()) {
if (!empty($instance['title'])) {
echo $args['before_title'] . __('Profile Links') . $args['after_title'];
}
$user_ID = get_current_user_id();
$profile_id = get_user_meta($user_ID, 'uiu_profile', TRUE);
$profile_link = !empty($profile_id) ? get_permalink($profile_id) : get_dashboard_url($user_ID);
?>
<ul class="menu user-menu">
<li class="menu-item"><a href="<?php echo $profile_link; ?>">My Profile</a> </li>
<li class="menu-item"><a href="<?php echo wp_logout_url(site_url()); ?>">Logout</a> </li>
</ul>
<?php
} else {
if (!empty($instance['title'])) {
echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
}
wp_login_form($args);
}
echo $args['after_widget'];
}
开发者ID:ergov2015,项目名称:rideflag,代码行数:35,代码来源:widgets-ajax-login.php
示例2: test_get_dashboard_url_for_administrator_of_different_site
/**
* @ticket 39065
*/
public function test_get_dashboard_url_for_administrator_of_different_site()
{
if (!is_multisite()) {
$this->markTestSkipped('Test only runs in multisite.');
}
$site_id = self::factory()->blog->create(array('user_id' => self::$user_id));
remove_user_from_blog(self::$user_id, get_current_blog_id());
$expected = get_admin_url($site_id);
$result = get_dashboard_url(self::$user_id);
remove_user_from_blog(self::$user_id, $site_id);
add_user_to_blog(get_current_blog_id(), self::$user_id, 'administrator');
wpmu_delete_blog($site_id, true);
$this->assertEquals($expected, $result);
}
开发者ID:CompositeUK,项目名称:clone.WordPress-Develop,代码行数:17,代码来源:getDashboardUrl.php
示例3: wp_admin_bar_my_account_menu
/**
* Add the "My Account" menu and all submenus.
*
* @since 3.1.0
*/
function wp_admin_bar_my_account_menu()
{
global $wp_admin_bar, $user_identity;
$user_id = get_current_user_id();
if (0 != $user_id) {
/* Add the 'My Account' menu */
$avatar = get_avatar(get_current_user_id(), 16);
$id = !empty($avatar) ? 'my-account-with-avatar' : 'my-account';
$wp_admin_bar->add_menu(array('id' => $id, 'title' => $avatar . $user_identity, 'href' => get_edit_profile_url($user_id)));
/* Add the "My Account" sub menus */
$wp_admin_bar->add_menu(array('parent' => $id, 'title' => __('Edit My Profile'), 'href' => get_edit_profile_url($user_id)));
if (is_multisite()) {
$wp_admin_bar->add_menu(array('parent' => $id, 'title' => __('Dashboard'), 'href' => get_dashboard_url($user_id)));
} else {
$wp_admin_bar->add_menu(array('parent' => $id, 'title' => __('Dashboard'), 'href' => admin_url()));
}
$wp_admin_bar->add_menu(array('parent' => $id, 'title' => __('Log Out'), 'href' => wp_logout_url()));
}
}
开发者ID:nervniy,项目名称:nervniy.github.com,代码行数:24,代码来源:admin-bar.php
示例4: do_action
?>
</span>
</a>
</h1>
<?php
do_action('in_admin_header');
$links = array();
// Generate user profile and info links.
$links[5] = sprintf(__('Howdy, %1$s'), $user_identity);
$links[8] = '<a href="profile.php" title="' . esc_attr__('Edit your profile') . '">' . __('Your Profile') . '</a>';
if (is_multisite() && is_super_admin()) {
if (!is_network_admin()) {
$links[10] = '<a href="' . network_admin_url() . '" title="' . (!empty($update_title) ? $update_title : esc_attr__('Network Admin')) . '">' . __('Network Admin') . (!empty($total_update_count) ? ' (' . number_format_i18n($total_update_count) . ')' : '') . '</a>';
} else {
$links[10] = '<a href="' . get_dashboard_url(get_current_user_id()) . '" title="' . esc_attr__('Site Admin') . '">' . __('Site Admin') . '</a>';
}
}
$links[15] = '<a href="' . wp_logout_url() . '" title="' . esc_attr__('Log Out') . '">' . __('Log Out') . '</a>';
$links = apply_filters('admin_user_info_links', $links, $current_user);
ksort($links);
// Trim whitespace and pipes from links, then convert to list items.
$links = array_map('trim', $links, array_fill(0, count($links), " |\n\t"));
$howdy = array_shift($links);
$links_no_js = implode(' | ', $links);
$links_js = '<li>' . implode('</li><li>', $links) . '</li>';
?>
<div id="wphead-info">
<div id="user_info">
<p class="hide-if-js"><?php
开发者ID:fka2004,项目名称:webkit,代码行数:31,代码来源:admin-header.php
示例5: wp_user_profiles_get_admin_area_url
/**
* Return the admin area URL for a user
*
* This function exists to make it easier to determine which admin area URL to
* use in what context. It also comes with its own filter to make it easier to
* target its usages.
*
* @since 0.1.0
*
* @param int $user_id
* @param string $scheme
* @param array $args
*
* @return string
*/
function wp_user_profiles_get_admin_area_url($user_id = 0, $scheme = '', $args = array())
{
$file = wp_user_profiles_get_file();
// User admin (multisite only)
if (is_user_admin()) {
$url = user_admin_url($file, $scheme);
// Network admin editing
} elseif (is_network_admin()) {
$url = network_admin_url($file, $scheme);
// Fallback dashboard
} else {
$url = get_dashboard_url($user_id, $file, $scheme);
}
// Add user ID to args array for other users
if (!empty($user_id) && $user_id !== get_current_user_id()) {
$args['user_id'] = $user_id;
}
// Add query args
$url = add_query_arg($args, $url);
// Filter and return
return apply_filters('wp_user_profiles_get_admin_area_url', $url, $user_id, $scheme, $args);
}
开发者ID:LaconicTranslator,项目名称:wp-user-profiles,代码行数:37,代码来源:functions.php
示例6: result_message
/**
* Print result message box error / updated
* @since 0.2.0
* @param array $form_message messages to print
*/
public static function result_message($form_message)
{
if (isset($form_message['error'])) {
echo '<div id="message" class="error">';
echo ' <p>' . $form_message['error'] . '</p>';
echo '</div>';
} else {
echo '<div id="message" class="updated">';
echo ' <p>';
echo ' <strong>' . $form_message['msg'] . ' : ' . '</strong>';
switch_to_blog($form_message['site_id']);
$user = get_current_user_id();
echo ' <a href="' . get_dashboard_url($user) . '">' . MUCD_NETWORK_PAGE_DUPLICATE_DASHBOARD . '</a> - ';
echo ' <a href="' . get_site_url() . '">' . MUCD_NETWORK_PAGE_DUPLICATE_VISIT . '</a> - ';
echo ' <a href="' . admin_url('customize.php') . '">' . MUCD_NETWORK_CUSTOMIZE . '</a>';
if ($log_url = MUCD_Duplicate::log_url()) {
echo ' - <a href="' . $log_url . '">' . MUCD_NETWORK_PAGE_DUPLICATE_VIEW_LOG . '</a>';
}
restore_current_blog();
echo ' </p>';
echo '</div>';
}
}
开发者ID:pmatheus,项目名称:participacao-sitebase,代码行数:28,代码来源:admin.php
示例7: _mw_adminimize_restore_links
/**
* Add Site Link in Menu
*/
function _mw_adminimize_restore_links()
{
$_mw_adminimize_user_info = (int) _mw_adminimize_get_option_value('_mw_adminimize_user_info');
?>
<style type="text/css">
#mw_adminimize_admin_bar {
left: 0;
right: 0;
height: 33px;
z-index: 999;
border-bottom: 1px solid #dfdfdf;
}
#mw_adminimize_admin_bar #mw_title {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 16px;
color: #464646;
text-decoration: none;
padding-top: 8px;
display: block;
float: left;
}
#mw_adminimize_admin_bar #mw_title:hover {
text-decoration: underline;
}
#mw_adminimize_admin_bar #mw_adminimize_login {
padding: 8px 15px 0 0;
display: block;
float: right;
}
</style>
<div id="mw_adminimize_admin_bar">
<?php
echo '<a id="mw_title" href="' . home_url() . '" title="' . esc_attr__(get_bloginfo('name')) . '" target="_blank">' . get_bloginfo('name') . '</a>';
?>
<div id="mw_adminimize_login">
<?php
wp_get_current_user();
$current_user = wp_get_current_user();
if (empty($_mw_adminimize_user_info) || 0 === $_mw_adminimize_user_info || 3 === $_mw_adminimize_user_info) {
if (!$current_user instanceof WP_User) {
return;
}
echo ' ' . $current_user->user_login . ' ';
if (is_multisite() && is_super_admin()) {
if (!is_network_admin()) {
echo '| <a href="' . network_admin_url() . '" title="' . esc_attr__('Network Admin') . '">' . esc_attr__('Network Admin') . '</a>';
} else {
echo '| <a href="' . get_dashboard_url(get_current_user_id()) . '" title="' . esc_attr__('Site Admin') . '">' . esc_attr__('Site Admin') . '</a>';
}
}
}
if (empty($_mw_adminimize_user_info) || 0 == $_mw_adminimize_user_info || 2 == $_mw_adminimize_user_info || 3 == $_mw_adminimize_user_info) {
?>
| <?php
echo '<a href="' . wp_logout_url() . '" title="' . esc_attr__('Log Out') . '">' . esc_attr__('Log Out') . '</a>';
}
?>
</div>
</div>
<?php
}
开发者ID:brandonschlack,项目名称:lkwd10s,代码行数:67,代码来源:remove-admin-bar.php
示例8: to_wp_user_dashboard_uri
/**
* Constructs a URL leading to a WordPress® Dashboard URI (directory/file).
*
* @param null|integer|\WP_User|users $user User we're dealing with here.
* This defaults to a NULL value (indicating the current user).
*
* @param string $url_uri_query_fragment A full URL; or a partial URI;
* or only a query string, or only a fragment. Any of these can be parsed here.
*
* @param string $scheme Optional. To force a specific scheme (i.e. `//`, `http`, `https`).
*
* @return string URL leading to a WordPress® admin URI (directory/file).
*
* @throws exception If invalid types are passed through arguments list.
*/
public function to_wp_user_dashboard_uri($user = NULL, $url_uri_query_fragment = '', $scheme = '')
{
$this->check_arg_types($this->©user_utils->which_types(), 'string', 'string', func_get_args());
$user = $this->©user_utils->which($user);
if (!$user->has_id()) {
throw $this->©exception($this->method(__FUNCTION__) . '#id_missing', get_defined_vars(), $this->__('The `$user` has no ID (cannot get Dashboard URL).'));
}
$parts = $this->must_parse_uri_parts($url_uri_query_fragment);
if (substr($parts['path'], -1) !== '/' && !$this->©file->has_extension($parts['path'])) {
$parts['path'] = trailingslashit($parts['path']);
}
$url = get_dashboard_url($user->ID, $this->unparse($parts));
return $scheme ? $this->set_scheme($url, $scheme) : $url;
}
开发者ID:panvagenas,项目名称:x-related-posts,代码行数:29,代码来源:urls.php
示例9: process_expired_password
function process_expired_password()
{
// Process the expired password
// Create an errors object for us to use
$errors = new WP_Error();
if (isset($_POST['user_login'])) {
$user_name = sanitize_user($_POST['user_login']);
} else {
$user_name = '';
}
// 1. Check the user exists
if ($user = get_user_by('login', $user_name)) {
// User exists - move forward
// 2. Check the passwords have been entered and that they match
if (!isset($_POST['pass1-text']) && isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2']) {
$errors->add('password_reset_mismatch', __('The passwords do not match.', 'expirepassword'));
} else {
// 3. Check the key is valid - *before* accessing user data
// Get the stored key
$thekey = shrkey_get_usermeta_timed_oncer($user->ID, '_shrkey_password_expired_key');
// Get and parse the passed key
$passedkey = preg_replace('/[^a-z0-9]/i', '', $_POST['key']);
if (!empty($thekey) && !empty($passedkey) && $thekey == $passedkey) {
// The key is valid as well - so we need to check we are not resetting to the old password
$existingpassword = $this->get_users_password_hash($user->ID);
if (wp_check_password($_POST['pass1'], $existingpassword)) {
// The password matches - we don't want them setting the same password as before...
$errors->add('password_reset_sameh', __('Please choose a different password from your previous one.', 'expirepassword'));
} else {
$this->reset_expired_password($user, $_POST['pass1']);
// Remove the expired key setting
shrkey_delete_usermeta_oncer($user->ID, '_shrkey_password_expired');
// Check what we want to do next
$autoauthenticate = shrkey_get_option('_shrkey_expirepassword_autoauthenticate', 'no');
if ($autoauthenticate == 'no') {
// Send the user back to the login
login_header(__('Password Reset'), '<p class="message reset-pass">' . __('Your password has been reset, please login again with your <strong>new</strong> password.', 'expirepassword') . ' <a href="' . esc_url(wp_login_url()) . '">' . __('Log in', 'expirepassword') . '</a></p>');
login_footer();
exit;
} else {
// Authenticate and let them move on - first do some checks wp-login.php does
$secure_cookie = '';
// 1. See if we need to use ssl
if (get_user_option('use_ssl', $user->ID)) {
$secure_cookie = true;
force_ssl_admin(true);
}
// 2. check for a redirect
if (isset($_POST['redirect_to'])) {
$redirect_to = $_POST['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();
}
// 3. Run the filter for nicities
$redirect_to = apply_filters('login_redirect', $redirect_to, isset($_POST['redirect_to']) ? $_POST['redirect_to'] : '', $user);
// 4. Authenticate the user
wp_set_auth_cookie($user->ID, false, $secure_cookie);
// 5. Finally redirect to the correct place
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;
}
}
} else {
// The key either doesn't exist or doesn't match - possible security issue here, we want to produce an error message
// So we also blank the user out to force a re-login
unset($user);
// Add in our error message
login_header(__('Password Reset'), '<div id="login_error">' . __('Oops, something went wrong, please Login using your existing username and password and try again.', 'expirepassword') . ' <a href="' . esc_url(wp_login_url()) . '">' . __('Log in', 'expirepassword') . '</a></div>');
login_footer();
exit;
}
}
} else {
// The key either doesn't exist or doesn't match
$errors->add('password_expired_nouser', __('Could not change password, please try again.', 'expirepassword'));
}
// If we have errors then we need to display the form again
if ($errors->get_error_code()) {
// If we don't have a user record create a fake one
if (!isset($user) || is_wp_error($user)) {
$user = '';
}
// show the reset form again
$this->show_reset_password_form($user, wp_generate_password(35, false), isset($_POST['redirect_to']) ? $_POST['redirect_to'] : false, $errors);
}
exit;
//.........这里部分代码省略.........
开发者ID:newball,项目名称:expirepassword,代码行数:101,代码来源:public.expirepassword.php
示例10: template_redirect
//.........这里部分代码省略.........
wp_enqueue_script('user-profile');
break;
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) {
if ('email' == $this->get_option('login_type')) {
$user_login = isset($_POST['user_email']) ? $_POST['user_email'] : '';
} else {
$user_login = isset($_POST['user_login']) ? $_POST['user_login'] : '';
}
$user_email = isset($_POST['user_email']) ? $_POST['user_email'] : '';
$this->errors = 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 ($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 = $user->has_cap('read') ? admin_url('profile.php') : home_url();
}
}
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:akshayxhtmljunkies,项目名称:brownglock,代码行数:101,代码来源:class-theme-my-login.php
示例11: wp_admin_bar_dashboard_view_site_menu
/**
* Add the "Dashboard"/"Visit Site" menu.
*
* @since 3.2.0
* @deprecated 3.3.0
*/
function wp_admin_bar_dashboard_view_site_menu($wp_admin_bar)
{
_deprecated_function(__FUNCTION__, '3.3');
$user_id = get_current_user_id();
if (0 != $user_id) {
if (is_admin()) {
$wp_admin_bar->add_menu(array('id' => 'view-site', 'title' => __('Visit Site'), 'href' => home_url()));
} elseif (is_multisite()) {
$wp_admin_bar->add_menu(array('id' => 'dashboard', 'title' => __('Dashboard'), 'href' => get_dashboard_url($user_id)));
} else {
$wp_admin_bar->add_menu(array('id' => 'dashboard', 'title' => __('Dashboard'), 'href' => admin_url()));
}
}
}
开发者ID:rkglug,项目名称:WordPress,代码行数:20,代码来源:deprecated.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: wp_admin_bar_my_account_menu
/**
* Add the "My Account" submenu items.
*
* @since 3.1.0
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function wp_admin_bar_my_account_menu($wp_admin_bar)
{
$user_id = get_current_user_id();
$current_user = wp_get_current_user();
if (!$user_id) {
return;
}
if (current_user_can('read')) {
$profile_url = get_edit_profile_url($user_id);
} elseif (is_multisite()) {
$profile_url = get_dashboard_url($user_id, 'profile.php');
} else {
$profile_url = false;
}
$wp_admin_bar->add_group(array('parent' => 'my-account', 'id' => 'user-actions'));
$user_info = get_avatar($user_id, 64);
$user_info .= "<span class='display-name'>{$current_user->display_name}</span>";
if ($current_user->display_name !== $current_user->user_login) {
$user_info .= "<span class='username'>{$current_user->user_login}</span>";
}
$wp_admin_bar->add_menu(array('parent' => 'user-actions', 'id' => 'user-info', 'title' => $user_info, 'href' => $profile_url, 'meta' => array('tabindex' => -1)));
if (false !== $profile_url) {
$wp_admin_bar->add_menu(array('parent' => 'user-actions', 'id' => 'edit-profile', 'title' => __('Edit My Profile'), 'href' => $profile_url));
}
$wp_admin_bar->add_menu(array('parent' => 'user-actions', 'id' => 'logout', 'title' => __('Log Out'), 'href' => wp_logout_url()));
}
开发者ID:Garth619,项目名称:Femi9,代码行数:33,代码来源:admin-bar.php
示例14: 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
示例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(
|
请发表评论