Required Buddypress profile fields are not validated upon registration

I have required xprofile fields in my Buddypress setup. They appear on the registration form displayed by the Membership plugin but they are not validated when I submit the form.

I.e. when I register as a new user I can successfully submit the registration form without filling out required Buddypress xprofile fields that are displayed on the form.

I'm using Membership 3 RC 2
The particular subscription I'm testing is a free subscription

  • 3SixtyEvolve

    Hi @locomo

    Thanks for being part of our community and for your latest post.

    I have gone through all the settings on my own test site and can only see one place where you might have disabled the syncing between BuddyPress and WordPress (please see my screenshot for more details). Otherwise, if that's not it, it would be useful to see a link to your site.

    Let me know if that setting on the screenshot was disabled. Otherwise I will wait for a link to your site and for your site configuration (single/ multisite, latest versions etc).

    All the best and talk soon again.

    Gina

  • locomo

    Sure - happy to share what was going on. The way membership currently integrates with Buddypress is that only the required fields in the default Buddypress xprofile group appear on the registration form. I wanted all required Buddypress xprofile fields (even the ones in other xprofile groups) to be visible and validated on the membership registration form.

    This is what I did to modify Membership:
    Edited bp.registration.form.php:

    changed from
    <?php if ( function_exists('bp_is_active') && bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( 'profile_group_id=1&hide_empty_fields=0' ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>

    changed to
    <?php if ( function_exists('bp_is_active') && bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( 'hide_empty_fields=0' ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>

    added a new array to keep track of xprofile field ids that need to be validated:
    <?php $bp_profile_field_ids = array(); ?>

    changed all field types in the profile field loop
    changed from:
    <?php if ( 'textbox' == bp_get_the_profile_field_type() ) : ?>

    changed to:
    <?php if ( 'textbox' == bp_get_the_profile_field_type() && bp_get_the_profile_field_is_required() ) : ?>

    update the array created earlier after each pass through the profile field loop:

    <?php if ( bp_get_the_profile_field_is_required() ) : ?>
      <?php $bp_profile_field_ids[] = bp_get_the_profile_field_id(); ?>
    <?php endif; ?>

    update the hidden form field that passes the xprofile field ids that need to be validated:
    <input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php $asdf = implode(",", $bp_profile_field_ids); echo $asdf; ?>" />