Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'profile fields'

Viewing 25 results - 3,826 through 3,850 (of 4,122 total)
  • Author
    Search Results
  • Nightlyfe
    Participant

    Did this get released?

    #51279
    peterverkooijen
    Participant

    The html of the custom xprofile fields is generated by yet another function; get_edit_html() in bp-xprofile-classes.php. So if you want to change anything in the custom fields, including the * for required fields, you’ll need to copy/rename that function to bp-custom.php as well.

    EDIT: …which is not straightforward:

    Fatal error: Call to undefined method BP_XProfile_Field::custom_get_edit_html() in /serverpath/wp-content/mu-plugins/bp-custom.php on line 256

    #51271
    peterverkooijen
    Participant

    If so, the display name is still editable via the “Edit Profile” screen (like I stated above). Not sure what would happen if you attempted to change the display name… would it sync up with the usermeta table?

    Yes it does, that’s what the original xprofile_sync_wp_profile() already did, although I think you can turn it off in the admin area. Even if you did that, it wouldn’t mess up anything vital.

    My main concern was to consistently get a separate first name + last name in the database, because I need them for several other scripts. That only needs to happen on activation.

    Also I needed to learn how to use the fullname value in a function so I could autogenerate a username from it.

    Re: rearranging the signup page… BP 1.1 will enable you to move fields around on the sign up page. Check out testbp.org as an example of a customized register page.

    I need my site done before Labor Day or September 1st really. And the new more versatile template system does not solve any of my other issues.

    #51270
    peterverkooijen
    Participant

    Temporary solution how to customize registration form until 1.1 arrives, FYI and my own reference:

    Changed this line in function bp_show_register_page() in functions.php in my template:

    require ( BP_PLUGIN_DIR . '/bp-core/bp-core-signup.php' );

    to

    require ( 'custom-signup.php' );

    Copied bp-core-signup.php to the template folder, renamed to custom-signup.php.

    Go customize! :-)

    Unfortunately the custom fields are generated by yet another core function:

    do_action( 'signup_extra_fields', $errors );

    This action is associated with the function xprofile_add_signup_fields in bp-xprofile/bp-xprofile-signup.php.

    Copied the function to bp-custom.php, renamed action and function to custom_signup_extra_fields and custom_xprofile_add_signup_fields.

    Used this CSS trick to hide the avatar upload. Will use the same trick to hide the username field.

    #51269
    r-a-y
    Keymaster

    Oh sorry! I think I’m confusing what you’re trying to do.

    You’re trying to auto-generate the username based off the display name xprofile field, correct?

    If so, the display name is still editable via the “Edit Profile” screen (like I stated above). Not sure what would happen if you attempted to change the display name… would it sync up with the usermeta table?

    My guess from the post I wrote above is “no”, since you only have your function running when a user has activated their account. But I guess that’s the point!

    Re: rearranging the signup page… BP 1.1 will enable you to move fields around on the sign up page. Check out testbp.org as an example of a customized register page.

    #51259
    peterverkooijen
    Participant

    This function for bp-custom.php adds fullname from xprofile field_1 to wp_usermeta.

    function synchro_wp_usermeta($user_id, $password, $meta) {
    global $bp, $wpdb;

    $fullname = $meta[field_1];
    $space = strpos( $fullname, ' ' );

    if ( false === $space ) {
    $firstname = $fullname;
    $lastname = '';
    } else {
    $firstname = substr( $fullname, 0, $space );
    $lastname = trim( substr( $fullname, $space, strlen($fullname) ) );
    }

    update_usermeta( $user_id, 'nickname', $fullname );
    update_usermeta( $user_id, 'first_name', $firstname );
    update_usermeta( $user_id, 'last_name', $lastname );

    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $user_id ) );
    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_url = %s WHERE ID = %d", bp_core_get_user_domain( $user_id ), $user_id ) );
    }
    add_action( 'wpmu_activate_user', 'synchro_wp_usermeta', 10, 3);

    It shouldn’t be a big step to make the fullname lowercase, strip the spaces and store it as username.

    Make lowercase and strip space looks something like this:

    $str = strtolower($str);

    $str = str_replace(' ', '', $str);

    But does the system even allow changing the username at the wpmu_activate_user stage?

    The username is stored in four places in the database:

    wp_signups -> user_login

    wp_users -> user_login

    wp_users -> user_nicename (?!)

    wp_users -> user_url (as last part)

    Manually changing the username at these points in the database does NOT screw up my system. Login with email address continues to work fine with the same password. The profile page and links function as normal. :-)

    That is good news. It means it is possible to simply update the username from this same function.

    Now I just have to figure out the PHP and the queries for those four fields. Any pointers apprecriated!

    EDIT: Is $user_id a number or the username? That could complicate things…

    I assume $user_id is the username. Can I make this a two-stage rocket? First run the synchro_wp_usermeta function and then a separate function to deal with username, synchro_name_username? Put them in a plugin with something like this at the bottom?:

    add_action( 'wpmu_activate_user', 'synchro_wp_usermeta', 10, 3);
    add_action( 'wpmu_activate_user', 'synchro_name_username');

    Would that execute the functions in the right order?

    #51213
    peterverkooijen
    Participant

    BTW, how will fullname/firstname+lastname be handled in the new version? Will it be synchronized with wp_usermeta? Or will there be built-in fields in xprofile? Or another solution?

    Will there be an option to make them required? Will you offer an option to autogenerate username from fullname?

    Trying to decide which way to go for temporary solutions.

    peterverkooijen
    Participant

    When I do this:

    $fullname = $wpdb->get_var("SELECT meta FROM $wpdb->signups");
    echo $fullname;

    I get the serialized content of the first meta field in wp_signups:

    a:8:{s:7:"field_1";s:13:"Julius Caesar";s:18:"xprofile_field_ids";s:2:"1,";s:20:"avatar_image_resized";s:84:"/serverpath/wp-content/blogs.dir/1/files/avatars/0/caesar.jpg";s:21:"avatar_image_original";s:84:"/serverpath/wp-content/blogs.dir/1/files/avatars/0/caesar.jpg";s:6:"public";s:1:"1";s:7:"lang_id";i:1;s:8:"blogname";s:9:"theempire";s:10:"blog_title";s:16:"The Roman Empire";}

    The function inserted this crap also into the wp_usermeta fields. Success! (Sort of…)

    The bit of data I need is the fullname, the second bit, in this case ‘Julius Caesar’. I’d need the second bit of data from the user with the activation key.

    How would I add that to the query?

    I’ll first try this:

    $fullname = $wpdb->get_var("SELECT meta FROM $wpdb->signups WHERE activation_key = %s", $key);
    echo $fullname;

    Nothing… :-(

    I probably had to add $key as an argument. Trying again after some food…

    #51172
    gerikg
    Participant

    Sorry about the empty response. I thought I had it and when it didn’t work it screwed up. I edited out my post.

    Okay this is the fix I came out with. I created a new group in BP profile called signature and the field name signature too.

    In BBpress in the post.php I inserted (note I don’t know PHP, if anyone can shorten this would be appreciated):

    <?php if ( bp_has_profile('user_id='.get_post_author_id().'&profile_group_id=XXX') ) : ?>
    <?php while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
    <?php if ( bp_profile_group_has_fields() ) : ?>
    <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
    <?php if ( bp_field_has_data() ) : ?>
    <?php bp_the_profile_field_value() ?>
    <?php endif; ?>
    <?php endwhile; ?>
    <?php endif; ?>
    <?php endwhile; ?>
    <?php else: ?>
    <?php endif;?>

    Just replace XXX with your group id #, mine was 3.

    What it doesn’t do is toggle between signature, anyone want to try that?

    #51107
    omgitsrfb
    Participant

    I got the same issue with an upgrade to WPMU2.8.4a and BP1.0.3. Have two issues one is the one mentioned above by Arezki

    Hi all: I noticed that the listing of members using the alphabetical feature is not working. When you go to: http://tatazara.com/members and try any letter like F or S for Francis Stevenson, you get the link: http://tatazara.com/members#f but the page stays at /members directory. Any thought?

    and the other is that is gives me the ‘ol:

    No members found. Members must fill in at least one piece of profile data to show in member lists.

    error that othe threads have brought up.

    I upgraded to bp1.0.3 to get rid of the second issue per Andy’s instructions in a previous thread, but that didn’t help.

    the groups and blogs alpha directory work just as advertised but not the member alpha directory. yes, people have entered info into profile fields. the member search function works fine.

    Anyone got an idea about this? Could it be something with the different types of name fields?

    Thanks in advance for your advice.

    peterverkooijen
    Participant

    The ideal registration form would look like this:

    – fullname

    – email address

    Both fields would of course be mandatory. Ideally fullname would be checked for two or more parts, but xprofile_sync_wp_profile() can handle one part input and I can live with an occassional missing last name.

    I use a jQuery validation script on another form in my site, that I may also be able to use on the registration form. As far I understand it doesn’t interfere with anything on the server side.

    Username would be generated behind the scenes from fullname.

    Many other member information fields would be optional under edit profile.

    If I can figure out how to select fullname from meta in wp_signups, adapting xprofile_sync_wp_profile() shouldn’t be that difficult.

    Or are my latest attempts above still nowhere near a solution? If you see the obvious mistakes, please point them out.

    peterverkooijen
    Participant

    Mike Pratt, you’re right, that is one way to do it. Then you have the following fields on your registration form: username, name, first name, last name. That is an excellent solution if your aim is to annoy potential members.

    Another option is to use the default “fullname” field for first name and create a second one for last name, but then you’re kinda messing with the system and perhaps causing problems in the future. I have already done this solution in an earlier version. It’s my fallback option.

    But why would I have to create custom fields when WordPress already has the first_name and last_name fields in wp_usermeta? And there is even a ready-to-use Buddypress function that synchronizes the fields in wp_usermeta with the fullname in BP.

    Unfortunately at the moment that function is only run when the user updates his profile, so it’s completely useless. I’m trying to tweak it and make it useful and introduce to Buddypress the wonders of a first_name, last_name in the database. (Wow, I know…)

    Also I’d like to get rid of the username on the form, by autogenerating it from the fullname – make lowercase, take out spaces, store as username. That should be a relatively easy next step once I’ve figured out how to use the fullname input from the registration form in a function.

    Also I wasn’t able to get bp tags working in a plugin, where I had no problem pulling first_name and last_name from wp_usermeta, providing they were available…

    This should be a really easy plugin for any php coder, but as Jeff Sayre has pointed out, having a somewhat clean, professional user registration in Buddypress is reserved for those well-versed in the codebase or with deep-enough pockets.

    @Mariusooms, I need to finish the site before Labor Day, with a related event on September 22nd. When will bp1.0.3 be released?

    I’ll figure it out somehow, with or without the help of WordPress insiders.

    Mike Pratt
    Participant

    Am I missing something? All I had to do to achieve a solution to this was to create two new fields in basic called FirstName and LastName and make them mandatory on signup. Now I can ref them all I want in code later. What is the point of this huge plugin? Thee is no need to be dependent on users updating their profile since they can join without filling in these fields.

    peterverkooijen
    Participant

    I had a good feeling about this attempt, but still nothing in wp_usermeta:

    function synchro_wp_usermeta($user_id, $password, $meta) {
    global $bp, $wpdb;

    $field_ids = $meta['xprofile_field_ids'];
    $field_ids = explode( ',', $field_ids );

    // Loop through each bit of profile data and save it to profile.
    for ( $i = 0; $i < count($field_ids); $i++ ) {
    if ( empty( $field_ids[$i] ) ) continue;

    $field_value = $meta["field_{$field_ids[$i]}"];
    }

    $fullname = $field_value['field_1'];
    $space = strpos( $fullname, ' ' );

    if ( false === $space ) {
    $firstname = $fullname;
    $lastname = '';
    } else {
    $firstname = substr( $fullname, 0, $space );
    $lastname = trim( substr( $fullname, $space, strlen($fullname) ) );
    }

    update_usermeta( $bp->loggedin_user->id, 'nickname', $fullname );
    update_usermeta( $bp->loggedin_user->id, 'first_name', $firstname );
    update_usermeta( $bp->loggedin_user->id, 'last_name', $lastname );

    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $bp->loggedin_user->id ) );
    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_url = %s WHERE ID = %d", bp_core_get_user_domain( $bp->loggedin_user->id ), $bp->loggedin_user->id ) );
    }
    add_action( 'wpmu_activate_user', 'synchro_wp_usermeta', 10, 3);

    This version messes up registration:

    function synchro_wp_usermeta($user_id, $password, $meta) {
    global $bp_user_signup_meta, $bp, $wpdb;

    $fields = BP_XProfile_Field::get_signup_fields();

    $field_ids = $meta['xprofile_field_ids'];
    $field_ids = explode( ',', $field_ids );

    // Loop through each bit of profile data and save it to profile.
    for ( $i = 0; $i < count($field_ids); $i++ ) {
    if ( empty( $field_ids[$i] ) ) continue;

    $field_value = $meta["field_{$field_ids[$i]}"];
    }

    $fullname = $field_value['field_1'];
    $space = strpos( $fullname, ' ' );

    if ( false === $space ) {
    $firstname = $fullname;
    $lastname = '';
    } else {
    $firstname = substr( $fullname, 0, $space );
    $lastname = trim( substr( $fullname, $space, strlen($fullname) ) );
    }

    update_usermeta( $bp->loggedin_user->id, 'nickname', $fullname );
    update_usermeta( $bp->loggedin_user->id, 'first_name', $firstname );
    update_usermeta( $bp->loggedin_user->id, 'last_name', $lastname );

    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $bp->loggedin_user->id ) );
    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_url = %s WHERE ID = %d", bp_core_get_user_domain( $bp->loggedin_user->id ), $bp->loggedin_user->id ) );
    }
    add_action( 'wpmu_activate_user', 'synchro_wp_usermeta', 10, 3);

    Registration goes through as normal. The user gets one email with the activation link. But the page on the link says ‘Your account has already been activated. You can now log in with the account details that were emailed to you.’ No email arrives.

    So the above code hijacks activation without doing anything (probably because $bp_user_signup_meta was added). Still nothing in wp_usermeta either.

    My problem is getting the $fullname from $meta. I don’t understand the array stuff. I’m basically just guessing.

    If there are any php coders out there that can spot any obvious mistakes or can suggest other things to try, please help me out.

    peterverkooijen
    Participant

    You mean the 3 at the end of that line would fix that? I’ll try that next with a previous version of my code.

    Just for the record, this attempt again didn’t work. No errors, but nothing in wp_usermeta either:

    function synchro_wp_usermeta() {
    global $bp_user_signup_meta, $bp, $wpdb;

    $fields = BP_XProfile_Field::get_signup_fields();

    if ( $fields ) {
    foreach ( $fields as $field ) {

    $value = $_POST['field_' . $field->id];

    }
    }

    $fullname = $value['field_1'];
    $space = strpos( $fullname, ' ' );

    if ( false === $space ) {
    $firstname = $fullname;
    $lastname = '';
    } else {
    $firstname = substr( $fullname, 0, $space );
    $lastname = trim( substr( $fullname, $space, strlen($fullname) ) );
    }

    update_usermeta( $bp->loggedin_user->id, 'nickname', $fullname );
    update_usermeta( $bp->loggedin_user->id, 'first_name', $firstname );
    update_usermeta( $bp->loggedin_user->id, 'last_name', $lastname );

    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $bp->loggedin_user->id ) );
    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_url = %s WHERE ID = %d", bp_core_get_user_domain( $bp->loggedin_user->id ), $bp->loggedin_user->id ) );
    }
    add_action( 'wpmu_new_user', 'synchro_wp_usermeta' );

    This fixes the missing arguments errors, but still nothing in wp_usermeta. I’ll need to figure out how to serialize (?) $meta and extract $fullname from it:

    function synchro_wp_usermeta($user_id, $password, $meta) {
    global $bp, $wpdb;

    $fullname = $meta['field_1'];
    $space = strpos( $fullname, ' ' );

    if ( false === $space ) {
    $firstname = $fullname;
    $lastname = '';
    } else {
    $firstname = substr( $fullname, 0, $space );
    $lastname = trim( substr( $fullname, $space, strlen($fullname) ) );
    }

    update_usermeta( $bp->loggedin_user->id, 'nickname', $fullname );
    update_usermeta( $bp->loggedin_user->id, 'first_name', $firstname );
    update_usermeta( $bp->loggedin_user->id, 'last_name', $lastname );

    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $bp->loggedin_user->id ) );
    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_url = %s WHERE ID = %d", bp_core_get_user_domain( $bp->loggedin_user->id ), $bp->loggedin_user->id ) );
    }
    add_action( 'wpmu_activate_user', 'synchro_wp_usermeta', 10, 3);

    peterverkooijen
    Participant

    Thanks for the additional clues DJPaul!

    In the latest attempt I was going back to my first approach, trying to catch the input straight from the form, so that has to run on initial user registration, not on activation.

    Or is user_register not used in Buddypress at all? Is there a wpmu or bp equivalent I could try? Should I use wpmu_create_user? According to this blog post:

    the do_action for wpmu_new_user is directly at the bottom of wpmu_create_user in the wp-includes/wpmu-functions.php the wpmu_create_user gets sent the username password and email and checks if the username or email exists, if not create the new user in the database and assign a user_id to the return, also assigning capabilities and level … this happens on *all* levels of registration and is the perfect hook point to add them into the database

    the do_action do_action( ‘wpmu_new_user’, $user_id ); so you get the immediate user_id soon as it’s created which you can use in your table

    Apparantly this is like a flowchart of registration events in wpmu (wp-includes/wpmu-default-filters.php):

    add_filter ( 'wpmu_validate_user_signup', 'signup_nonce_check' );
    add_action ( 'init', 'maybe_add_existing_user_to_blog' );
    add_filter ( 'xmlrpc_methods', 'attach_wpmu_xmlrpc' );
    add_filter ( 'wp_authenticate_user', 'wordpressmu_authenticate_siteadmin', 10, 2 );
    add_action ( 'wpmu_new_user', 'newuser_notify_siteadmin' );
    add_action ( 'wpmu_activate_user', 'add_new_user_to_blog', 10, 3 );
    add_action ( 'sanitize_user', 'strtolower_usernames', 10, 3 );

    Should I focus on these wpmu action hooks instead of regular wp hook? Does bp have a list like this somewhere?

    I couldn’t figure out how to serialize that $meta data and extract the fullname from it, so I abandoned the approach hooking into wpmu_activate_user for now. Also when I put in the $user_id and $password arguments I got the error messages about missing arguments. wtf?!

    I think this bit of code grabs the input from the registration form:

    $fields = BP_XProfile_Field::get_signup_fields();

    if ( $fields ) {
    foreach ( $fields as $field ) {

    $value = $_POST['field_' . $field->id];

    fullname is the input from field_1, but I don’t know how to finish the php to get to $fullname = … . The two latest attempts above did not work.

    I have to give up for now. Deadline at my day job coming up…

    peterverkooijen
    Participant

    The last attempt in the previous post does not work. No error messages, registration goes through as normal, but nothing in wp_usermeta.

    This also has no effect:

    function synchro_wp_usermeta() {
    global $bp_user_signup_meta, $bp, $wpdb;

    $fields = BP_XProfile_Field::get_signup_fields();

    if ( $fields ) {
    foreach ( $fields as $field ) {

    $fullname = $_POST['field_1'];
    }
    }

    $space = strpos( $fullname, ' ' );

    if ( false === $space ) {
    $firstname = $fullname;
    $lastname = '';
    } else {
    $firstname = substr( $fullname, 0, $space );
    $lastname = trim( substr( $fullname, $space, strlen($fullname) ) );
    }

    update_usermeta( $bp->loggedin_user->id, 'nickname', $fullname );
    update_usermeta( $bp->loggedin_user->id, 'first_name', $firstname );
    update_usermeta( $bp->loggedin_user->id, 'last_name', $lastname );

    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $bp->loggedin_user->id ) );
    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_url = %s WHERE ID = %d", bp_core_get_user_domain( $bp->loggedin_user->id ), $bp->loggedin_user->id ) );
    }
    add_action( 'user_register', 'synchro_wp_usermeta' );

    Please, I need feedback to finish this function/plugin. A real coder can spot the problem probably immediately. Please point it out, don’t leave me hanging.

    peterverkooijen
    Participant

    Stuck again…

    I think this is the function that takes the input from the registration form (in bp_xprofile_classes.php):

    function get_signup_fields() {
    global $wpdb, $bp;

    $sql = $wpdb->prepare( "SELECT f.id FROM {$bp->profile->table_name_fields} AS f, {$bp->profile->table_name_groups} AS g WHERE g.name = %s AND f.parent_id = 0 AND g.id = f.group_id ORDER BY f.id", get_site_option('bp-xprofile-base-group-name') );

    if ( !$temp_fields = $wpdb->get_results($sql) )
    return false;

    for ( $i = 0; $i < count($temp_fields); $i++ ) {
    $fields[] = new BP_XProfile_Field( $temp_fields[$i]->id, null, false );
    }

    return $fields;
    }

    Then bp-xprofile-signup.php has the function xprofile_load_signup_meta() with this bit:

    $fields = BP_XProfile_Field::get_signup_fields();

    if ( $fields ) {
    foreach ( $fields as $field ) {

    $value = $_POST['field_' . $field->id];

    Followed by lots of validation code. For my purposes I could end it here:

    $fullname = $_POST['field_1'];

    Trying to put it together:

    function synchro_wp_usermeta() {
    global $bp_user_signup_meta, $bp, $wpdb;

    $fields = BP_XProfile_Field::get_signup_fields();

    if ( $fields ) {
    foreach ( $fields as $field ) {

    $value = $_POST['field_' . $field->id];

    }
    }

    $fullname = $value['field_1'];
    $space = strpos( $fullname, ' ' );

    if ( false === $space ) {
    $firstname = $fullname;
    $lastname = '';
    } else {
    $firstname = substr( $fullname, 0, $space );
    $lastname = trim( substr( $fullname, $space, strlen($fullname) ) );
    }

    update_usermeta( $bp->loggedin_user->id, 'nickname', $fullname );
    update_usermeta( $bp->loggedin_user->id, 'first_name', $firstname );
    update_usermeta( $bp->loggedin_user->id, 'last_name', $lastname );

    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $bp->loggedin_user->id ) );
    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_url = %s WHERE ID = %d", bp_core_get_user_domain( $bp->loggedin_user->id ), $bp->loggedin_user->id ) );
    }
    add_action( 'user_register', 'synchro_wp_usermeta' );

    Does this make sense? Can any of the more experienced php-coders please point out the obvious mistakes?

    peterverkooijen
    Participant

    This latest attempt had no error messages, but also no first_name and last_name were added to wp_usermeta:

    function synchro_wp_usermeta($meta) {
    global $bp, $wpdb;

    $fullname = $meta['field_1'];
    $space = strpos( $fullname, ' ' );

    if ( false === $space ) {
    $firstname = $fullname;
    $lastname = '';
    } else {
    $firstname = substr( $fullname, 0, $space );
    $lastname = trim( substr( $fullname, $space, strlen($fullname) ) );
    }

    update_usermeta( $bp->loggedin_user->id, 'nickname', $fullname );
    update_usermeta( $bp->loggedin_user->id, 'first_name', $firstname );
    update_usermeta( $bp->loggedin_user->id, 'last_name', $lastname );

    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $bp->loggedin_user->id ) );
    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_url = %s WHERE ID = %d", bp_core_get_user_domain( $bp->loggedin_user->id ), $bp->loggedin_user->id ) );
    }
    add_action( 'wpmu_activate_user', 'synchro_wp_usermeta' );

    ?>

    I suspect I need some additional code to “unpack” $meta.

    In a previous attempt I tried this, based on a function in bp-xprofile-signup.php:

    // Extract signup meta fields to fill out profile
    $field_ids = $meta['xprofile_field_ids'];
    $field_ids = explode( ',', $field_ids );

    // Loop through each bit of profile data and save it to profile.
    for ( $i = 0; $i < count($field_ids); $i++ ) {
    if ( empty( $field_ids[$i] ) ) continue;

    $field_value = $meta["field_{$field_ids[$i]}"];

    $field = new BP_XProfile_ProfileData();
    $field->user_id = $user_id;
    $field->value = $field_value;
    $field->field_id = $field_ids[$i];
    $field->last_updated = time();
    }

    $fullname = $field->field_1;

    I think it crashed my server…

    I’ll need help (un?)serializing that $meta array. I’ll study up on that stuff later.

    But first I’ll try if bp_user_fullname() works. After some late lunch…

    Paul Wong-Gibbs
    Keymaster

    Hey, the entire best way to get a response from me is to give my plugins some advertising!

    Let’s see. Those thingies are called arguments. As you have probably figured out, ‘wpmu_activate_user’ action is called from wpmu-functions.php line 1208 (on my development server files, at least).

    First two arguments are obvious. When an account is registered, a new records is made in the wp_signups database table. There is a column called $meta, which is a seralized PHP array. $meta as in the wpmu_activate_user argument, is the unseralized version of that array for the user that has just activated his/her account.

    On one of my test users, it seems to contains keys: field_1, xprofile_fields_ids (not sure), avatar_image_resized (bool) and avatar_image_original (bool).

    So as you’ve suggested above, I reckon you can just use $meta[‘field_1’]. Let us know!

    EDIT: the code you’ve pasted above. You’ll need to have all three arguments, even if you don’t want to use them all. You can miss out ones AFTER the one you want, but you can’t miss anything out before the one you wish to use.

    peterverkooijen
    Participant

    arezki, there is a Users to CSV plugin. Not sure if it also exports data from Buddypress’ xprofile table, but perhaps you could expand it.

    Getting data from the database is relatively simple. You could just write your own SQL queries as well, if you can figure out how and where the data is stored, which is not at all straightforward in the wp-wpmu-bp patchwork.

    My original question was about something else; how does data move from registration form to the database?

    I’m trying to identify what bit of code “picks up” the input from the ‘* Name’ field, id/name = “field_1”. Is it this function?:

    function xprofile_extract_signup_meta( $user_id, $meta ) {
    // Extract signup meta fields to fill out profile
    $field_ids = $meta['xprofile_field_ids'];
    $field_ids = explode( ',', $field_ids );

    // Loop through each bit of profile data and save it to profile.
    for ( $i = 0; $i < count($field_ids); $i++ ) {
    if ( empty( $field_ids[$i] ) ) continue;

    $field_value = $meta["field_{$field_ids[$i]}"];

    $field = new BP_XProfile_ProfileData();
    $field->user_id = $user_id;
    $field->value = $field_value;
    $field->field_id = $field_ids[$i];
    $field->last_updated = time();

    $field->save();
    }

    update_usermeta( $user_id, 'last_activity', time() );
    }

    For a plugin I need SOMETHING HERE = $fullname. The SOMETHING HERE should be the input value for field_1 from the registration form.

    I get lost in the php in the array stuff. Please help if anyone can give any more clues!

    peterverkooijen
    Participant

    Would this work? Does it make sense?

    function synchro_wp_usermeta($user_id, $meta ) {
    global $bp, $wpdb;

    // Extract signup meta fields to fill out profile
    $field_ids = $meta['xprofile_field_ids'];
    $field_ids = explode( ',', $field_ids );

    // Loop through each bit of profile data and save it to profile.
    for ( $i = 0; $i < count($field_ids); $i++ ) {
    if ( empty( $field_ids[$i] ) ) continue;

    $field_value = $meta["field_{$field_ids[$i]}"];

    $field = new BP_XProfile_ProfileData();
    $field->user_id = $user_id;
    $field->value = $field_value;
    $field->field_id = $field_ids[$i];
    $field->last_updated = time();
    }

    $fullname = $field->field_1;
    $space = strpos( $fullname, ' ' );

    if ( false === $space ) {
    $firstname = $fullname;
    $lastname = '';
    } else {
    $firstname = substr( $fullname, 0, $space );
    $lastname = trim( substr( $fullname, $space, strlen($fullname) ) );
    }

    update_usermeta( $bp->loggedin_user->id, 'nickname', $fullname );
    update_usermeta( $bp->loggedin_user->id, 'first_name', $firstname );
    update_usermeta( $bp->loggedin_user->id, 'last_name', $lastname );

    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $bp->loggedin_user->id ) );
    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_url = %s WHERE ID = %d", bp_core_get_user_domain( $bp->loggedin_user->id ), $bp->loggedin_user->id ) );
    }
    add_action( 'user_register', 'synchro_wp_usermeta' );

    I’m looking for a way to define $fullname, to take the input from field_1 (* Name).

    Please, anyone, help. I’ve been struggling with this for about four months now.

    EDIT: Tried the code in bp_custom.php. It produced (?) a nasty database error, may have even crashed the server… :-(

    peterverkooijen
    Participant

    bp-xprofile-signup.php has a promising looking function:

    xprofile_on_activate_user()

    When a user activates their account, move the extra field data to the correct tables.

    function xprofile_extract_signup_meta( $user_id, $meta ) {
    // Extract signup meta fields to fill out profile
    $field_ids = $meta['xprofile_field_ids'];
    $field_ids = explode( ',', $field_ids );

    // Loop through each bit of profile data and save it to profile.
    for ( $i = 0; $i < count($field_ids); $i++ ) {
    if ( empty( $field_ids[$i] ) ) continue;

    $field_value = $meta["field_{$field_ids[$i]}"];

    $field = new BP_XProfile_ProfileData();
    $field->user_id = $user_id;
    $field->value = $field_value;
    $field->field_id = $field_ids[$i];
    $field->last_updated = time();

    $field->save();
    }

    update_usermeta( $user_id, 'last_activity', time() );
    }

    Does $field->save(); have something to do with function save()?

    function update_usermeta actually updates wp_usermeta. So why is field_1 not stored in wp_usermeta?! Very confused…

    #50981
    peterverkooijen
    Participant

    I’m not creating a plugin from scratch or doing any complicated manipulations on the data. I’m only trying to pre-populate fields in the RSVP form in this Event Registration plugin.

    Adding the ‘echo’ didn’t fix the problem. It probably is something stupid like that.

    Which code actually pulls the data from xprofile? I couldn’t make much sense of function bp_user_fullname(). The real magic apparently happens somewhere else.

    Getting regular wp data works fine. If I could figure out how to consistently synchronize firstname and last name between xprofile and wp_usermeta, that would solve the problem as well.

    #50847

    In reply to: BP in Education…

    peterverkooijen
    Participant

    How do you handle fullname/real name in these school community sites:

    1. students can just fill in whatever they like in the standard BP fullname field?

    2. or did you add code to check for a two-part name?

    3. or do you have code that synchronizes the firstname and lastname fields in wp_usermeta with the fullname field in BP xprofile?

    4. did you create a custom xprofile field for lastname and use fullname for first name?

    I still haven’t figured out what the best solution is…

    Also how do you keep track of members when the admin areas use the usernames? Did you find a way to synchronize usernames with fullnames? What about blognames/urls?

    Chris Kenniburg, is your Set Privacy plugin available somewhere? Is it a regular WP(MU) plugin?

Viewing 25 results - 3,826 through 3,850 (of 4,122 total)
Skip to toolbar