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

Seems logical for any other network, not for buddypress though 🙁

We all know the extended user profiles in buddypress – problem is, even though some fields are marked as required, that “required” seems to have no real significance for buddypress developers. So we have some “required” fields, which nobody EVER asks the user to fill in … “Great” job so far …

So the question is… how can we force the newly registered user to first fill in all those required fields from the extended user profile, BEFORE he is able to use anything on the site !?

Like he registers with name, prename, email and once he logs in he will be presented with a page/screen where he will have to first complete all the other missing required fileds, before he’ll be able to see ANY content on the site !!?

Anyone please an idea about how to achieve this? It’s more than 1 year I think I search for a solution … 🙁

4 Answers
4

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