bp_nouveau_signup_form( string $section = 'account_details' )

Output the signup form for the requested section

Description

Parameters

$section

(Optional) The section of fields to get 'account_details' or 'blog_details'. Default: 'account_details'.

Default value: 'account_details'

Source

File: bp-templates/bp-nouveau/includes/template-tags.php

2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
function bp_nouveau_signup_form( $section = 'account_details' ) {
    $fields = bp_nouveau_get_signup_fields( $section );
    if ( ! $fields ) {
        return;
    }
 
    foreach ( $fields as $name => $attributes ) {
        list( $label, $required, $value, $attribute_type, $type, $class ) = array_values( $attributes );
 
        // Text fields are using strings, radios are using their inputs
        $label_output = '<label for="%1$s">%2$s</label>';
        $id           = $name;
        $classes      = '';
 
        if ( $required ) {
            /* translators: Do not translate placeholders. 2 = form field name, 3 = "(required)". */
            $label_output = __( '<label for="%1$s">%2$s %3$s</label>', 'buddyboss' );
        }
 
        // Output the label for regular fields
        if ( 'radio' !== $type ) {
            if ( $required ) {
                printf( $label_output, esc_attr( $name ), esc_html( $label ), '' );
            } else {
                printf( $label_output, esc_attr( $name ), esc_html( $label ) );
            }
 
            if ( ! empty( $value ) && is_callable( $value ) ) {
                $value = call_user_func( $value );
            }
 
        // Handle the specific case of Site's privacy differently
        } elseif ( 'signup_blog_privacy_private' !== $name ) {
            ?>
                <span class="label">
                    <?php esc_html_e( 'I would like my site to appear in search engines, and in public listings around this network.', 'buddyboss' ); ?>
                </span>
            <?php
        }
 
        // Set the additional attributes
        if ( $attribute_type ) {
            $existing_attributes = array();
 
            if ( ! empty( $required ) ) {
                $existing_attributes = array( 'aria-required' => 'true' );
 
                /**
                 * The blog section is hidden, so let's avoid a browser warning
                 * and deal with the Blog section in Javascript.
                 */
                if ( $section !== 'blog_details' ) {
                    // Removed because we don't have to display the browser error message.
                    //$existing_attributes['required'] = 'required';
                }
            }
 
            $attribute_type = ' ' . bp_get_form_field_attributes( $attribute_type, $existing_attributes );
        }
 
        // Specific case for Site's privacy
        if ( 'signup_blog_privacy_public' === $name || 'signup_blog_privacy_private' === $name ) {
            $name      = 'signup_blog_privacy';
            $submitted = bp_get_signup_blog_privacy_value();
 
            if ( ! $submitted ) {
                $submitted = 'public';
            }
 
            $attribute_type = ' ' . checked( $value, $submitted, false );
        }
 
        // Do not run function to display errors for the private radio.
        if ( 'private' !== $value ) {
 
            /**
             * Fetch & display any BP member registration field errors.
             *
             * Passes BP signup errors to Nouveau's template function to
             * render suitable markup for error string.
             */
            if ( isset( buddypress()->signup->errors[ $name ] ) ) {
                nouveau_error_template( buddypress()->signup->errors[ $name ] );
                $invalid = 'invalid';
            }
        }
 
        if ( isset( $invalid ) && isset( buddypress()->signup->errors[ $name ] ) ) {
            if ( ! empty( $class ) ) {
                $class = $class . ' ' . $invalid;
            } else {
                $class = $invalid;
            }
        }
 
        if ( $class ) {
            $class = sprintf(
                ' class="%s"',
                esc_attr( join( ' ', array_map( 'sanitize_html_class', explode( ' ', $class ) ) ) )
            );
        }
 
        // Set the input.
        $field_output = sprintf(
            '<input type="%1$s" name="%2$s" id="%3$s" %4$s value="%5$s" %6$s />',
            esc_attr( $type ),
            esc_attr( $name ),
            esc_attr( $id ),
            $class// Constructed safely above.
            esc_attr( $value ),
            $attribute_type // Constructed safely above.
        );
 
        // Not a radio, let's output the field
        if ( 'radio' !== $type ) {
            if ( 'signup_blog_url' !== $name ) {
                print( $field_output );  // Constructed safely above.
 
            // If it's the signup blog url, it's specific to Multisite config.
            } elseif ( is_subdomain_install() ) {
                // Constructed safely above.
                printf(
                    '%1$s %2$s . %3$s',
                    is_ssl() ? 'https://' : 'http://',
                    $field_output,
                    bp_signup_get_subdomain_base()
                );
 
            // Subfolders!
            } else {
                printf(
                    '%1$s %2$s',
                    home_url( '/' ),
                    $field_output  // Constructed safely above.
                );
            }
 
        // It's a radio, let's output the field inside the label
        } else {
            // $label_output and $field_output are constructed safely above.
            printf( $label_output, esc_attr( $name ), $field_output . ' ' . esc_html( $label ) );
        }
 
        // Password strength is restricted to the signup_password field
        if ( 'signup_password' === $name ) :
        ?>
            <div id="pass-strength-result"></div>
        <?php
        endif;
    }
 
    /**
     * Fires and displays any extra member registration details fields.
     *
     * This is a variable hook that depends on the current section.
     *
     * @since BuddyPress 1.9.0
     */
    do_action( "bp_{$section}_fields" );
}

Changelog

Changelog
Version Description
BuddyPress 3.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.