Skip to content

Commit 2212c0f

Browse files
committed
Use wp_login_url() for login links when signing up for a new blog or activating a new blog on Multisite.
Fixes #31495 Props GregLone for the intial patch git-svn-id: https://develop.svn.wordpress.org/trunk@34790 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 2ef0449 commit 2212c0f

2 files changed

Lines changed: 41 additions & 8 deletions

File tree

src/wp-activate.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,12 @@ function wpmu_activate_stylesheet() {
115115
<p><span class="h3"><?php _e('Password:'); ?></span> <?php echo $result['password']; ?></p>
116116
</div>
117117

118-
<?php if ( $url && $url != network_home_url( '', 'http' ) ) : ?>
119-
<p class="view"><?php printf( __('Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>'), $url, $url . 'wp-login.php' ); ?></p>
118+
<?php if ( $url && $url != network_home_url( '', 'http' ) ) :
119+
switch_to_blog( (int) $result['blog_id'] );
120+
$login_url = wp_login_url();
121+
restore_current_blog();
122+
?>
123+
<p class="view"><?php printf( __( 'Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>' ), $url, esc_url( $login_url ) ); ?></p>
120124
<?php else: ?>
121125
<p class="view"><?php printf( __('Your account is now activated. <a href="%1$s">Log in</a> or go back to the <a href="%2$s">homepage</a>.' ), network_site_url('wp-login.php', 'login'), network_home_url() ); ?></p>
122126
<?php endif;

src/wp-signup.php

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,28 +353,57 @@ function validate_another_blog_signup() {
353353
*/
354354
$meta = apply_filters( 'add_signup_meta', $meta_defaults );
355355

356-
wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, $wpdb->siteid );
357-
confirm_another_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta);
356+
$blog_id = wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, $wpdb->siteid );
357+
358+
if ( is_wp_error( $blog_id ) ) {
359+
return false;
360+
}
361+
362+
confirm_another_blog_signup( $domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta, $blog_id );
358363
return true;
359364
}
360365

361366
/**
362367
* Confirm a new site signup
363368
*
364369
* @since MU
370+
* @since 4.4.0 Added the `$blog_id` parameter.
365371
*
366372
* @param string $domain The domain URL
367373
* @param string $path The site root path
368374
* @param string $blog_title The blog title
369375
* @param string $user_name The username
370376
* @param string $user_email The user's email address
371-
* @param array $meta Any additional meta from the 'add_signup_meta' filter in validate_blog_signup()
377+
* @param array $meta Any additional meta from the 'add_signup_meta' filter in validate_blog_signup()
378+
* @param int $blog_id The blog ID
372379
*/
373-
function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = array() ) {
380+
function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = array(), $blog_id = 0 ) {
381+
382+
if ( $blog_id ) {
383+
switch_to_blog( $blog_id );
384+
$home_url = home_url( '/' );
385+
$login_url = wp_login_url();
386+
restore_current_blog();
387+
} else {
388+
$home_url = 'http://' . $domain . $path;
389+
$login_url = 'http://' . $domain . $path . 'wp-login.php';
390+
}
391+
392+
$site = sprintf( '<a href="%1$s">%2$s</a>',
393+
esc_url( $home_url ),
394+
$blog_title
395+
);
396+
374397
?>
375-
<h2><?php printf( __( 'The site %s is yours.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2>
398+
<h2><?php printf( __( 'The site %s is yours.' ), $site ); ?></h2>
376399
<p>
377-
<?php printf( __( '<a href="http://%1$s">http://%2$s</a> is your new site. <a href="%3$s">Log in</a> as &#8220;%4$s&#8221; using your existing password.' ), $domain.$path, $domain.$path, "http://" . $domain.$path . "wp-login.php", $user_name ) ?>
400+
<?php printf(
401+
__( '<a href="%1$s">%2$s</a> is your new site. <a href="%3$s">Log in</a> as &#8220;%4$s&#8221; using your existing password.' ),
402+
esc_url( $home_url ),
403+
untrailingslashit( $domain . $path ),
404+
esc_url( $login_url ),
405+
$user_name
406+
); ?>
378407
</p>
379408
<?php
380409
/**

0 commit comments

Comments
 (0)