Function
Get signup form for a user.
tml_ms_get_user_signup_form( string $user_name = '', string $user_email = '', WP_Error $errors = '' )
Parameters
-
$user_namestring Default'' - The username.
-
$user_emailstring Default'' - The user's email.
-
$errorsWP_Error Default'' - The WP_Error object.
Source
function tml_ms_get_user_signup_form( $user_name = '', $user_email = '', $errors = '' ) {
if ( ! is_wp_error( $errors ) ) {
$errors = new WP_Error();
}
// phpcs:disable WordPress.Security.NonceVerification.Missing -- read-only: mirrors the field's pre-filled default, not processed/acted on.
$signup_for = isset( $_POST['signup_for'] ) ? esc_html( $_POST['signup_for'] ) : 'blog';
// phpcs:enable WordPress.Security.NonceVerification.Missing
/** This filter is documented in wp-signup.php */
$filtered_results = apply_filters( 'signup_user_init', compact( 'user_name', 'user_email', 'errors' ) );
$user_name = $filtered_results['user_name'];
$user_email = $filtered_results['user_email'];
$errors = $filtered_results['errors'];
$form = tml_get_form( 'user_signup' );
$fields = compact( 'user_name', 'user_email' );
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(
array(
'before' => '<h2>' . sprintf(
__( 'Get your own %s account in seconds' ), // phpcs:ignore WordPress.WP.I18n.MissingArgDomain, WordPress.WP.I18n.MissingTranslatorsComment -- reusing WP core's translated "Get your own %s account in seconds" string (see wp-signup.php), not a TML-specific string; no translators comment since it never enters TML's own .pot.
get_network()->site_name
) . '</h2>',
)
);
}
Uses
Used by
Changelog
| Version | Description |
|---|---|
| 7.0 | Introduced. |