Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/19/2021 01:02:18 PM (4 years ago)
Author:
imath
Message:

BP Blocks: add a link to reset the user password into the Login Form

  • add a setting to let the Admin choose whether to show this link from the block’s inspector settings.
  • Include this link under the "Log In" button if this setting is active.

Props ellucinda

Fixes #8100

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-blocks.php

    r13108 r13111  
    222222 */
    223223function bp_blocks_get_login_widget_registration_link( $content = '', $args = array() ) {
    224     if ( isset( $args['form_id'] ) && 'bp-login-widget-form' === $args['form_id'] && bp_get_signup_allowed() ) {
    225         $content .= sprintf(
    226             '<p class="bp-login-widget-register-link"><a href="%1$s">%2$s</a></p>',
    227             esc_url( bp_get_signup_page() ),
    228             esc_html__( 'Register', 'buddypress' )
    229         );
     224    if ( isset( $args['form_id'] ) && 'bp-login-widget-form' === $args['form_id'] ) {
     225        if ( bp_get_signup_allowed() ) {
     226            $content .= sprintf(
     227                '<p class="bp-login-widget-register-link"><a href="%1$s">%2$s</a></p>',
     228                esc_url( bp_get_signup_page() ),
     229                esc_html__( 'Register', 'buddypress' )
     230            );
     231        }
     232
     233        if ( isset( $args['include_pwd_link'] ) && true === $args['include_pwd_link'] ) {
     234            $content .= sprintf(
     235                '<p class="bp-login-widget-pwd-link"><a href="%1$s">%2$s</a></p>',
     236                esc_url( wp_lostpassword_url( bp_get_root_domain() ) ),
     237                esc_html__( 'Lost your password?', 'buddypress' )
     238            );
     239        }
    230240    }
    231241
     
    261271        $attributes,
    262272        array(
    263             'title' => '',
     273            'title'         => '',
     274            'forgotPwdLink' => false,
    264275        )
    265276    );
     
    339350    } else {
    340351        $action_output = '';
     352        $pwd_link      = (bool) $block_args['forgotPwdLink'];
     353
    341354        if ( has_action( 'bp_before_login_widget_loggedout' ) ) {
    342355            ob_start();
     
    358371        $widget_content .= wp_login_form(
    359372            array(
    360                 'echo'           => false,
    361                 'form_id'        => 'bp-login-widget-form',
    362                 'id_username'    => 'bp-login-widget-user-login',
    363                 'label_username' => __( 'Username', 'buddypress' ),
    364                 'id_password'    => 'bp-login-widget-user-pass',
    365                 'label_password' => __( 'Password', 'buddypress' ),
    366                 'id_remember'    => 'bp-login-widget-rememberme',
    367                 'id_submit'      => 'bp-login-widget-submit',
     373                'echo'             => false,
     374                'form_id'          => 'bp-login-widget-form',
     375                'id_username'      => 'bp-login-widget-user-login',
     376                'label_username'   => __( 'Username', 'buddypress' ),
     377                'id_password'      => 'bp-login-widget-user-pass',
     378                'label_password'   => __( 'Password', 'buddypress' ),
     379                'id_remember'      => 'bp-login-widget-rememberme',
     380                'id_submit'        => 'bp-login-widget-submit',
     381                'include_pwd_link' => $pwd_link,
    368382            )
    369383        );
Note: See TracChangeset for help on using the changeset viewer.