Skip to:
Content

BuddyPress.org

Changeset 12875


Ignore:
Timestamp:
04/01/2021 08:42:37 AM (6 months ago)
Author:
imath
Message:

Improve possible customization of invalid signup field error message

Adds a new parameter ($fieldname) to the anonymous function firing the bp_members_signup_error_message and includes it into the filter params.

It's now easier to customize the error message according to the concerned invalid signup field name.

Fixes #8449

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/screens/register.php

    r12679 r12875  
    156156                 *
    157157                 * @since 1.5.0
    158                  *
    159                  * @param string $value Error message wrapped in html.
     158                 * @since 8.0.0 Adds the `$fieldname` parameter to the anonymous function.
     159                 *
     160                 * @param string $value     Error message wrapped in html.
     161                 * @param string $fieldname The name of the signup field.
    160162                 */
    161                 add_action( 'bp_' . $fieldname . '_errors', function() use ( $error_message ) {
    162                     echo apply_filters( 'bp_members_signup_error_message', "<div class=\"error\">" . $error_message . "</div>" );
     163                add_action( 'bp_' . $fieldname . '_errors', function() use ( $error_message, $fieldname ) {
     164                    /**
     165                     * Filter here to edit the error message about the invalid field value.
     166                     *
     167                     * @since 1.5.0
     168                     * @since 8.0.0 Adds the `$fieldname` parameter.
     169                     *
     170                     * @param string $value     Error message wrapped in html.
     171                     * @param string $fieldname The name of the signup field.
     172                     */
     173                    echo apply_filters( 'bp_members_signup_error_message', "<div class=\"error\">" . $error_message . "</div>", $fieldname );
    163174                } );
    164175            }
Note: See TracChangeset for help on using the changeset viewer.