Skip to:
Content
Pages
Categories
Search
Top
Bottom

Buddypress-Validate required registration field – but not with bp-profile-setup

  • Avatar of valuser
    valuser
    Participant

    @valuser

    (i assume it can be done as captchas do it!)

    Have added a field to the registration form like this : (—-> my problem is to validate this field)

    1) added these functions to functions.php

    /* Add sign-up field to BuddyPress sign-up array */
    `function anewbp_custom_user_signup_field( $usermeta ) {
    $usermeta = $_POST;
    return $usermeta;
    }
    add_filter( ‘bp_signup_usermeta’, ‘anewbp_custom_user_signup_field’ );`

    /* Add field_name from sign-up to usermeta on activation */
    `function anewbp_user_activate_field( $signup ) {

    update_usermeta( $signup, ‘eyecolor’, $signup );
    return $signup;
    }
    add_filter( ‘bp_core_activate_account’, ‘anewbp_user_activate_field’ );`

    2) have added this to register.php at an appropriate place

    `
    `

    So far so good.

    However I need this to be a REQUIRED field and am having problems !!

    What have I tried ?

    a)
    `function anewbp_check_validation(){
    global $bp;
    $anewbp_custom_user_signup_field_txt = $_POST;

    if (empty($anewbp_custom_user_signup_field_txt) || $anewbp_custom_user_signup_field_txt == ”) {
    $bp->signup->errors = __(‘Please complete this field’,’buddypress’);
    }
    return;
    }
    add_action(‘bp_signup_validate’, ‘ anewbp_check_validation’);`

    AND

    ` ` in register.php

    b)

    `function anewbp_check_validation(){
    global $bp;
    if (empty($_POST) || $_POST == ”) {
    $bp->signup->errors = __(‘Please complete this field’,’buddypress’);
    return;
    }
    }
    add_action(‘bp_signup_validate’, ‘anewbp_check_validation’);`

    AND

    ` ` in register.php

    and other variations. –> none have worked

    Where I’m coming from? —> Can follow and would be grateful for detailed instructions

    mainly a copy and paster but gradually getting an understanding of php.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Avatar of valuser
    valuser
    Participant

    @valuser

    In register.php I have changed to “.

    At the moment the validation appears to be happening as one can’t register without completing the field.
    BUT
    No validation NOTICE -Please complete this field- is being produced.
    It is not on the form and not there when you examine the form in firebug.
    So there appears just to be a small way to go. —-> Make the error notice appear
    Any help greatly appreciated -

    Avatar of SFMichael
    SFMichael
    Participant

    @sfmichael

    This is an old thread however I wanted to accomplish what you have asked and have got it to work.

    What i think happens is when bp_signup_validate is called triggering your validation function, the error should be added to an errors array. This will only be displayed when you call
    in register.php

    You code is right you just need to add:

    Hope this makes sense or is right :D

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

You must be logged in to reply to this topic.