/** * Action method for completing the 'comment' action. This action is used when leaving a comment. * * @param string $identity_url verified OpenID URL */ function openid_finish_comment($identity_url) { if ($_REQUEST['action'] != 'comment') { return; } if (empty($identity_url)) { openid_repost_comment_anonymously($_SESSION['openid_comment_post']); } openid_set_current_user($identity_url); if (is_user_logged_in()) { // simulate an authenticated comment submission $_SESSION['openid_comment_post']['author'] = null; $_SESSION['openid_comment_post']['email'] = null; $_SESSION['openid_comment_post']['url'] = null; } else { // try to get user data from the verified OpenID $user_data =& openid_get_user_data($identity_url); if (!empty($user_data['display_name'])) { $_SESSION['openid_comment_post']['author'] = $user_data['display_name']; } if (!empty($user_data['user_email'])) { $_SESSION['openid_comment_post']['email'] = $user_data['user_email']; } $_SESSION['openid_comment_post']['url'] = $identity_url; } // record that we're about to post an OpenID authenticated comment. // We can't actually record it in the database until after the repost below. $_SESSION['openid_posted_comment'] = true; $comment_page = defined('OPENID_COMMENTS_POST_PAGE') ? OPENID_COMMENTS_POST_PAGE : 'wp-comments-post.php'; openid_repost(site_url("/{$comment_page}"), array_filter($_SESSION['openid_comment_post'])); }
/** * Action method for completing the 'login' action. This action is used when a user is logging in from * wp-login.php. * * @param string $identity_url verified OpenID URL */ function openid_finish_login($identity_url) { if ($_REQUEST['action'] != 'login') { return; } $redirect_to = urldecode($_REQUEST['redirect_to']); if (empty($identity_url)) { $url = get_option('siteurl') . '/wp-login.php?openid_error=' . urlencode(openid_message()); wp_safe_redirect($url); exit; } openid_set_current_user($identity_url); if (!is_user_logged_in()) { if (get_option('users_can_register')) { $user_data =& openid_get_user_data($identity_url); $user = openid_create_new_user($identity_url, $user_data); openid_set_current_user($user->ID); } else { // TODO - Start a registration loop in WPMU. $url = get_option('siteurl') . '/wp-login.php?registration_closed=1'; wp_safe_redirect($url); exit; } } if (empty($redirect_to)) { $redirect_to = 'wp-admin/'; } if ($redirect_to == 'wp-admin/') { if (!current_user_can('edit_posts')) { $redirect_to .= 'profile.php'; } } if (!preg_match('#^(http|\\/)#', $redirect_to)) { $wpp = parse_url(get_option('siteurl')); $redirect_to = $wpp['path'] . '/' . $redirect_to; } wp_safe_redirect($redirect_to); exit; }