Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 25 replies - 526 through 550 (of 690 total)
  • @peterverkooijen

    Participant

    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.

    Are you sure about that? With the three arguments I get two ‘Missing argument’ error messages. With only $meta there are no errors – although it doesn’t do anything either…

    EDIT: Tried the code below. Again one ‘Missing argument’ error. Registration goes through as normal, but nothing in wp_usermeta:

    function synchro_wp_usermeta($user_id, $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 = $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' );

    @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…

    @peterverkooijen

    Participant

    Thanks Paul!

    $meta[‘field_1’] definitely looks like something to try, although I still totally don’t “get” serialized PHP arrays.

    I was also wondering if I could just bp_user_fullname() at this point, before activation.

    Trying both now…

    EDIT:

    function synchro_wp_usermeta($user_id, $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' );

    ?>

    Registration process works fine, but I with this error in the screen on activation:

    Warning: Missing argument 2 for synchro_wp_usermeta() in /serverpath/wp-content/mu-plugins/bp-custom.php on line 187

    I had taken $password out. Thought I didn’t need it. Will try again with it added back in….

    EDIT2: Adding $password only gives me a second error:

    Warning: Missing argument 2 for synchro_wp_usermeta() in /serverpath/wp-content/mu-plugins/bp-custom.php on line 187

    Warning: Missing argument 3 for synchro_wp_usermeta() in /serverpath/wp-content/mu-plugins/bp-custom.php on line 187

    Can I just take $user_id out? Is all the information I need already in that wpmu_activate_user action?

    I’ll try that next, after deleting test users. Running out of email addresses…

    @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…

    @peterverkooijen

    Participant

    I think the code that actually processes the input from the registration form is in bp_xprofile/bp-xprofile-classes.php, Class BP_XProfile_ProfileData etc.

    Input data is apparently stored with function save() and the input data is a combination of field_id + value for the same $this->id.

    In the html ‘* Name’ is an optional field with the name/id field_1. I guess that’s the field_id?

    Now I need to figure out how to get a definition of $fullname out of that. I’ll look for more examples/tutorials how processing form input in php actually works…

    @peterverkooijen

    Participant

    Thanks r-a-y.

    I can’t make much sense of most of that code. Does function bp_core_signup_show_user_form take the input from the form? Or does it only output the form? I guess the latter.

    I think the code that actually processes the input is in bp_xprofile/bp-xprofile-classes.php, Class BP_XProfile_ProfileData etc. Or bp-xprofile-signup.php?

    Back to the other thread to see if it gets me any further…

    @peterverkooijen

    Participant

    You’re right r-a-y. Tried it. It had no effect on Buddypress’ registration form.

    Back to my previous attempt; I’m stuck at intercepting fullname input from the Buddypress registration form. Do you know how?

    Based on code in another plugin I put together something based on ‘$input_data’:

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

    $post_data = array();
    foreach ($input_data as $varname => $varvalue) {
    $post_data[$varname] = $varvalue;
    }

    $fullname = $post_data[fullname];
    ...

    But I don’t know if that $input_data is a standard wp tag or something else. Also the structure of the xprofile tables is very different from the structure of the regular wp users tables, so I’m not sure if that ‘$input_data as $varname => $varvalue’ is applicable.

    Where is the code that processes data input from the Buddypress registration form? I’d like to use that as example, but have no clue where it is.

    @peterverkooijen

    Participant

    Here is a plugin that “forces users to provide first and last name upon registration” and stores them in wp_usermeta.

    Would this plugin be compatible with Buddypress? Looking into it now…

    @peterverkooijen

    Participant

    Another attempt! What I really need is a variation of the xprofile_sync_wp_profile function that takes $fullname directly from the registration form and can be executed on user_register.

    That shouldn’t be too hard, right?

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

    $fullname = GET FROM THE REGISTRATION FORM INPUT
    $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 have another plugin that also takes data from the registration form. That plugin has this in the code: $input_data. Is that standard wp? There’s nothing about it in the Codex.

    That other plugin has this function, minus irrelevant bits:

    function subscribe($input_data) {

    // $post_data = array();
    foreach ($input_data as $varname => $varvalue) {
    $post_data[$varname] = $varvalue;
    }

    }
    $post_data='action=subscribe&group_ids[]='.$this->lid.'&email_address='.$this->email_id.'&firstname='.$this->name_id;

    So in my case that last line would become something like this?:

    $post_data= 'first_name='.$this->first_name;

    Of course somehow put together in one function. Like this?:

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

    $post_data = array();
    foreach ($input_data as $varname => $varvalue) {
    $post_data[$varname] = $varvalue;
    }

    $fullname = $post_data[fullname];
    $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' );

    Can anyone please help? What should I put here for the “fullname” field?:

    $fullname = $post_data[fullname];

    Or is the entire approach wrong?

    @peterverkooijen

    Participant

    It’s basically impossible. You have to hack core files.

    @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.

    @peterverkooijen

    Participant

    Thanks JJJ.

    I can’t get anything to show up with <?php bp_user_fullname() ?> and $bp in global.

    I also noticed that bp_user_email does not exist, so I guess I’ll need custom functions to get data from xprofile.

    The function get_currentuserinfo() is in wp-includes/pluggable.php. Should I try to adapt that code to xprofile? Or is there a better starting point somewhere?

    I can’t code php from scratch, I have to puzzle it together from examples… ;-|

    @peterverkooijen

    Participant

    Thanks Jeff Sayre!

    The plugin has a very messy structure. I’ve tried with $bp added to global in several functions in the plugin, both in the main file and the file with the form. Nothing has any effect.

    Are there any downsides to adding $bp if it’s not strictly needed? Can you make any plugin “Buddypress ready” by just adding that $bp to global?

    I did get regular wp data working with help from their forum. I had to add this to the php:

    global $current_user;
    get_currentuserinfo();

    Does Buddypress have something like that? Anything else I can try?

    In reply to: SVN version?

    @peterverkooijen

    Participant

    I think the latest test version is here, but apparently Buddypress 1.1 will be released next week, so it may not be worth the hassle to install the test version.

    @peterverkooijen

    Participant

    Bussypress?

    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?

    @peterverkooijen

    Participant

    Privacy controls are in the development roadmap, I think for version 1.3, release date tbd.

    Until then you could use this code, but it doesn’t have a working ‘restricted area’ message with ajax or redirect, so you’ll have to code something yourself if you want to use it.

    In this thread Chris Kenniburg mentions a Set Privacy Settings plugin.

    In reply to: New Groupblog Plugin

    @peterverkooijen

    Participant

    OK, good point Mariusooms. I’m eager to test this… :-)

    In reply to: New Groupblog Plugin

    @peterverkooijen

    Participant

    I guess this is the latest trunk. Is there a faster way to download this thing or is file by file the only option?

    In reply to: New Groupblog Plugin

    @peterverkooijen

    Participant

    Where can I get “the latest trunk of BP”?

    In reply to: Main Navigation help

    @peterverkooijen

    Participant

    @peterverkooijen

    Participant

    WordPress MU and Buddypress have separate profile/user management tables that aren’t synchronized and in some ways clash. End users will see different profile editing screens, in wp-admin and buddypress front-end, with different data that have nothing to do with eachother. Users are identified by full name, username, nickname, blogname or whatever depending on where in the system you are and how it’s configured. It’s a confusing mess and my pet peeve.

    But I’m not even sure if that’s relevant to your problem, so I removed the rant.

    @peterverkooijen

    Participant

    Not usernames, full names. And the only one that is found is by full name, not username.

    After some testing I think you have to be friends. Maybe there’s a setting somewhere…

Viewing 25 replies - 526 through 550 (of 690 total)
Skip to toolbar