How to override a plugin function without modifying the plugin's code?

176
June 10, 2018, at 5:40 PM

Please consider the following function from a plugin I'm using for my Wordpress site:

function rcp_validate_user_data() {
    $user = array();
    ...

    if( $user['need_new'] ) {
        if( username_exists( $user['login'] ) ) {
            // Username already registered
            rcp_errors()->add( 'username_unavailable', __( 'Username already taken', 'rcp' ), 'register' );
        }
        if( ! rcp_validate_username( $user['login'] ) ) {
            // invalid username
            rcp_errors()->add( 'username_invalid', __( 'Invalid username', 'rcp' ), 'register' );
        }
        if( empty( $user['login'] ) ) {
            // empty username
            rcp_errors()->add( 'username_empty', __( 'Please enter a username', 'rcp' ), 'register' );
        }
        if( ! is_email( $user['email'] ) ) {
            //invalid email
            rcp_errors()->add( 'email_invalid', __( 'Invalid email', 'rcp' ), 'register' );
        }
        if( email_exists( $user['email'] ) ) {
            //Email address already registered
            rcp_errors()->add( 'email_used', __( 'Email already registered', 'rcp' ), 'register' );
        }
        if( empty( $user['password'] ) ) {
            // passwords do not match
            rcp_errors()->add( 'password_empty', __( 'Please enter a password', 'rcp' ), 'register' );
        }
        if( $user['password'] !== $user['password_confirm'] ) {
            // passwords do not match
            rcp_errors()->add( 'password_mismatch', __( 'Passwords do not match', 'rcp' ), 'register' );
        }
    }
    return apply_filters( 'rcp_user_registration_data', $user );
}

How can I customize the error messages without changing the plugin's code? Is it even possible?

READ ALSO
Shorter way of writing nested PHP for loops

Shorter way of writing nested PHP for loops

Is there any way to write multiple nested loops with a shorter syntax in PHP?

148
How to use validationDefault method in cakephp 3

How to use validationDefault method in cakephp 3

I am trying to use validationDefault method in my model UsersTable :

216
after submitting the values in the database table are not updated

after submitting the values in the database table are not updated

I am new to PHPWhen I am trying to update or modify my form then it is not getting updated in the phpmyadmin database table

124
Removing file permissions from a PHP file

Removing file permissions from a PHP file

When I change permissions from 644 to 600 on a PHP file and try refreshing my file in the browser it still shows the fileAt first I thought it was because the browser was caching it, but I tried Incognito mode and even tried another browser and it was still showing...

120