Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Overriding bp_core_validate_user_signup function


  • Hope
    Participant

    @amalsh

    Hi dears,

    I’m trying to override the bp_core_validate_user_signup function to add extra necessary checks but it’s not working. What I’ve done is the following:

    add_filter('bp_core_validate_user_signup','validate_user_signup',10,2);
    function validate_user_signup($user_name, $user_email)
    {
     // the modified code
    }

    An error occurs when trying to sign up:
    “Missing argument 2 for validate_user_signup() in …..\wp-content\themes\custom-community-child\functions.php on line 709”

    Have I missed something? Am I doing it wrong? Any help is highly appreciated
    Hope

Viewing 3 replies - 1 through 3 (of 3 total)

  • shanebp
    Moderator

    @shanebp

    Please use the code button when posting code.

    You can’t over-ride that function, but if you aren’t using multisite, you can use the filter hook:
    apply_filters( 'bp_core_validate_user_signup', $result );
    Which only provides one argument: $result

    So your function should be :

    add_filter('bp_core_validate_user_signup', 'validate_user_signup', 10, 1);
    function validate_user_signup($result) {
      // access to the user name: $result['user_name']
      // access to the user email: $result['user_email']
      //what is in errors: var_dump( $result['errors'] )
      return $result;
    }

    danbp
    Participant

    @danbp

    Function doc says:
    * @param array $result Results of user validation including errors, if any.
    Original function fires

    $result = array(
    	'user_name'  => $user_name,
    	'user_email' => $user_email,
    	'errors'     => $errors,
    );

    Try

    function validate_user_signup( $result ) {
      // the modified code and at least something like
      return $result;
    }
    add_filter( 'bp_core_validate_user_signup', 'validate_user_signup' );

    Hope
    Participant

    @amalsh

    Thanks a lot guys, it’s working now 🙂 Many thanks…

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Overriding bp_core_validate_user_signup function’ is closed to new replies.
Skip to toolbar