signup_another_blog

Allow returning users to sign up for another site.

Description

signup_another_blog( (string) $blogname = '', (string) $blog_title = '', (string) $errors = '' ); 

Parameters (3)

0. $blogname — Optional. (string) => ''
The new site name
1. $blog_title — Optional. (string) => ''
The new site title.
2. $errors — Optional. (string) => ''
A WP_Error object containing existing errors. Defaults to empty string.

Usage

  1. if ( !function_exists( 'signup_another_blog' ) ) { 
  2. require_once '/wp-signup.php'; 
  3.  
  4. // The new site name 
  5. $blogname = ''; 
  6.  
  7. // The new site title. 
  8. $blog_title = ''; 
  9.  
  10. // A WP_Error object containing existing errors. Defaults to empty string. 
  11. $errors = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = signup_another_blog($blogname, $blog_title, $errors); 
  15.  

Defined (1)

The function is defined in the following location(s).

/wp-signup.php  
  1. function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) { 
  2. $current_user = wp_get_current_user(); 
  3.  
  4. if ( ! is_wp_error($errors) ) { 
  5. $errors = new WP_Error(); 
  6.  
  7. $signup_defaults = array( 
  8. 'blogname' => $blogname,  
  9. 'blog_title' => $blog_title,  
  10. 'errors' => $errors 
  11. ); 
  12.  
  13. /** 
  14. * Filters the default site sign-up variables. 
  15. * @since 3.0.0 
  16. * @param array $signup_defaults { 
  17. * An array of default site sign-up variables. 
  18. * @type string $blogname The site blogname. 
  19. * @type string $blog_title The site title. 
  20. * @type WP_Error $errors A WP_Error object possibly containing 'blogname' or 'blog_title' errors. 
  21. * } 
  22. */ 
  23. $filtered_results = apply_filters( 'signup_another_blog_init', $signup_defaults ); 
  24.  
  25. $blogname = $filtered_results['blogname']; 
  26. $blog_title = $filtered_results['blog_title']; 
  27. $errors = $filtered_results['errors']; 
  28.  
  29. echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_network()->site_name ) . '</h2>'; 
  30.  
  31. if ( $errors->get_error_code() ) { 
  32. echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>'; 
  33. ?> 
  34. <p><?php printf( __( 'Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. There is no limit to the number of sites you can have, so create to your heart’s content, but write responsibly!' ), $current_user->display_name ) ?></p> 
  35.  
  36. <?php 
  37. $blogs = get_blogs_of_user($current_user->ID); 
  38. if ( !empty($blogs) ) { ?> 
  39.  
  40. <p><?php _e( 'Sites you are already a member of:' ) ?></p> 
  41. <ul> 
  42. <?php foreach ( $blogs as $blog ) { 
  43. $home_url = get_home_url( $blog->userblog_id ); 
  44. echo '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>'; 
  45. } ?> 
  46. </ul> 
  47. <?php } ?> 
  48.  
  49. <p><?php _e( 'If you’re not going to use a great site domain, leave it for a new user. Now have at it!' ) ?></p> 
  50. <form id="setupform" method="post" action="wp-signup.php"> 
  51. <input type="hidden" name="stage" value="gimmeanotherblog" /> 
  52. <?php 
  53. /** 
  54. * Hidden sign-up form fields output when creating another site or user. 
  55. * @since MU 
  56. * @param string $context A string describing the steps of the sign-up process. The value can be 
  57. * 'create-another-site', 'validate-user', or 'validate-site'. 
  58. */ 
  59. do_action( 'signup_hidden_fields', 'create-another-site' ); 
  60. ?> 
  61. <?php show_blog_form($blogname, $blog_title, $errors); ?> 
  62. <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site' ) ?>" /></p> 
  63. </form> 
  64. <?php