How to force buddypress users to complete profile after registration? [closed]

Use wp_redirect() and admin_url() to redirect the user to his profile page if the custom buddypress user meta data isn’t completely filled.

From another answer, I’ve seen that there’s the following function: bp_get_profile_field_data(). So you can easily build a template tag, that gives you either the full buddy user meta data set, or simply a FALSE back.

If you get a FALSE back, then you can redirect the user. On the get_user_metadata-hook, you already got the global $current_user set, so you can do the redirect on the template_redirect-hook.

function wpse57054_is_buddy_complete( $buddy_user_fields = array() )
{
    // convert single field keys to arrays
    $buddy_user_fields = (array) $buddy_user_fields;

    foreach ( $buddy_user_fields as $buddy_user_meta )
    {
        $data = bp_get_profile_field_data( array( 
            'field'   => $buddy_user_meta,
            'user_id' => wp_get_current_user()->id,
        ) );
        // One field empty/not filled: Abort and return FALSE
        if ( empty( $data ) )
            return false;
    }

    // Return the whole data set
    return $data;
}

Leave a Comment