Function
Get the signup form for another blog.
tml_ms_get_another_blog_signup_form( string $blogname = '', string $blog_title = '', WP_Error $errors = '' )
Parameters
-
$blognamestring Default'' - The blogname.
-
$blog_titlestring Default'' - The title of the site.
-
$errorsWP_Error Default'' - The WP_Error object.
Return
string
The blog signup form.
Source
function tml_ms_get_another_blog_signup_form( $blogname = '', $blog_title = '', $errors = '' ) {
$current_user = wp_get_current_user();
if ( ! is_wp_error( $errors ) ) {
$errors = new WP_Error();
}
/** This filter is documented in wp-signup.php */
$filtered_results = apply_filters( 'signup_another_blog_init', compact( 'blogname', 'blog_title', 'errors' ) );
$blogname = $filtered_results['blogname'];
$blog_title = $filtered_results['blog_title'];
$errors = $filtered_results['errors'];
// phpcs:disable WordPress.WP.I18n.MissingArgDomain, WordPress.WP.I18n.MissingTranslatorsComment -- these messages intentionally reuse WP core's translated wp-signup.php strings verbatim, not TML-specific strings; no translators comments since they never enter TML's own .pot.
$before = '<h2>' . sprintf(
__( 'Get <em>another</em> %s site in seconds' ),
get_network()->site_name
) . '</h2>';
$before .= '<p>' . sprintf( __( '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>';
$blogs = get_blogs_of_user( $current_user->ID );
if ( ! empty( $blogs ) ) {
$before .= '<p>' . __( 'Sites you are already a member of:' ) . '</p><ul>';
foreach ( $blogs as $blog ) {
$home_url = get_home_url( $blog->userblog_id );
$before .= '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>';
}
$before .= '</ul>';
}
$before .= '<p>' . __( 'If you are not going to use a great site domain, leave it for a new user. Now have at it!' ) . '</p>';
// phpcs:enable WordPress.WP.I18n.MissingArgDomain, WordPress.WP.I18n.MissingTranslatorsComment
$form = tml_get_form( 'another_blog_signup' );
$fields = compact( 'blogname', 'blog_title' );
foreach ( $fields as $field => $value ) {
$field = $form->get_field( $field );
if ( ! $field ) {
continue;
}
$error = $errors->get_error_message( $field->get_name() );
if ( $error ) {
$field->set_error( $error );
} elseif ( null !== $value ) {
$field->set_value( $value );
}
}
return $form->render( compact( 'before' ) );
}
Uses
Used by
Changelog
| Version | Description |
|---|---|
| 7.0 | Introduced. |