Search Results for 'profile fields'
-
AuthorSearch Results
-
August 15, 2009 at 2:58 pm #51047
peterverkooijen
ParticipantYou 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);August 15, 2009 at 2:14 pm #51045peterverkooijen
ParticipantThanks 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…
August 15, 2009 at 2:50 am #51033peterverkooijen
ParticipantThe 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.
August 15, 2009 at 2:15 am #51032peterverkooijen
ParticipantStuck 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?
August 14, 2009 at 8:20 pm #51026peterverkooijen
ParticipantThis 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…
August 14, 2009 at 7:28 pm #51023Paul Wong-Gibbs
KeymasterHey, 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.
August 14, 2009 at 6:02 pm #51021peterverkooijen
Participantarezki, 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!
August 14, 2009 at 4:12 am #50999peterverkooijen
ParticipantWould 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…
August 14, 2009 at 3:28 am #50998peterverkooijen
Participantbp-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…
August 13, 2009 at 7:26 pm #50981In reply to: bp tags not working in plugins?
peterverkooijen
ParticipantI’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.
August 10, 2009 at 5:00 pm #50847In reply to: BP in Education…
peterverkooijen
ParticipantHow 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?
August 8, 2009 at 11:23 pm #50790In reply to: Private xprofile fields
allenweiss
ParticipantAugust 8, 2009 at 9:37 pm #50787In reply to: Private xprofile fields
Paul Wong-Gibbs
KeymasterSee https://buddypress.org/forums/topic/faq-how-to-code-snippets-and-solutions, “How to hide selected profile fields” and “How to show secondary profile fields while hiding the “Base” profile fields in a user profile”.
These should get you started and this has been discussed elsewhere on the forums, so do a search.
August 4, 2009 at 11:20 pm #50610In reply to: Some valuable Tips with custom template
r-a-y
KeymasterFor #1, use Justin Tadlock’s Get The Image plugin in a loop. Or to make things easier, use Tadlock’s query_posts widget with Get The Image to easily define which posts to display. The Get The Image plugin does not cache the images though.
If you’re looking for image resizing / caching, try TimThumb from darrenhoyt.com… although I never have been able to get that working on WP.
For #2, there’s two plugins that I know of.
First one is The WordPress Bar. The second one is Pretty Link. It will not integrate with the BP bar… it will add another bar for external pages.
For #3, you’ll have to get creative with the xprofile fields. I have something setup with a BP install I’m working on, which manipulates the BP profile loop and uses CSS manipulation to display the social badges.
August 4, 2009 at 3:32 pm #50592TheEasyButton
ParticipantI apologize for not coming back sooner to say this is solved. Been having lots of computer issues. The reason the other code didn’t work was we were reading from the wrong table. Another table had the info we needed so I swapped it out and here’s what I’m using now. Hopefully this will come in handy for a lot of people.
This goes in the head
<!-- drop down search -->
<SCRIPT LANGUAGE="JavaScript">
function formHandler(form){
var URL = document.form.site.options[document.form.site.selectedIndex].value;
window.location.href = URL;
}
</SCRIPT>
<!-- end drop down search -->And this goes in the body
<!-- drop down search -->
<form name="form">
<select name="site" size=1>
<option value="">Blah Blah</option>
<?php
$field_id = 2; // this should be the id of the
// field you want, see your wp_bp_xprofile_fields
// database table to find it
global $wpdb;
$sql = "SELECT name FROM {$wpdb->base_prefix}bp_xprofile_fields WHERE parent_id = {$field_id} ORDER BY id DESC";
$result = $wpdb->get_col($wpdb->prepare($sql));
foreach($result as $row){
if(strlen($row) > 0){
$values[$row]++;
}
}
foreach($values as $key => $value){
echo "<option value=\"members/?s=$key\">$key</option>";
}
?>
</select>
<input type=button value="Go!" onClick="javascript:formHandler(this)">
</form>
<!-- end drop down search -->Don’t forget to change the number of the field. Thanks for all of your help
August 1, 2009 at 8:01 pm #50483In reply to: Accidently emptied the wp_users table
Jeff Sayre
ParticipantShould emptying the wp_users table ideally not also delete the connected user data in all the other tables, including xprofile? Or is that not how MySQL works?
No. The way the MySQL tables are set up for the *presses, is that there is no referential integrity. So, if you go into the DB’s backend and change a record or delete a record, it does not cascade the changes to sibling or child tables.
For example, assuming that you were allowed to do this by the table’s schema, if you changed the user ID in the wp_users table, it would not automatically update that ID in all other related tables to reflect the new ID number. Of course, the record ID fields in the *presses are automatically incremented, but you get the point.
Up until recently (past several years or so?), MySQL did not even offer the option of setting up tables with referential integrity. Now it does in a less-than-desirable way. It is not as simple to do in MySQL as it is in PostgreSQL, but it is straight forward enough. It requires that the tables have foreign keys and are created with the Type = InnoDB extension.
Personally, I’m a big PostgreSQL fan, but I do not want to start a PGsql vs MySQL flame war. If you use the *presses, you use MySQL. It’s as simple as that.
But, referential integrity is still not usually set up in many MySQL DBs. So, this is nothing peculiar to the *presses. Why? Because the developers make sure that the code takes care of the updates and cleanup.
This is one, of many, reasons why you really need to know what you are doing in the DB’s backend.
July 31, 2009 at 5:02 pm #50419In reply to: signup-description for core Name
Paul Wong-Gibbs
KeymasterYou would edit profile fields like this via /wp-admin/admin.php?page=buddypress/bp-xprofile.php on your installation, but it looks like you can’t add a description for the default Name theme (which you can’t edit or remove).
Nice catch. Report it as an enhancement suggestion on https://trac.buddypress.org/; use your username and password from this site to log in.
July 31, 2009 at 4:38 pm #50412peterverkooijen
ParticipantThe phplist-dual-registration plugin also takes input from registration. It has this function:
function subscribe($input_data) {
if (!wpphplist_check_curl()) {
echo 'CURL library not detected on system. Need to compile php with cURL in order to use this plug-in';
return(0);
}
// $post_data = array();
foreach ($input_data as $varname => $varvalue) {
$post_data[$varname] = $varvalue;
}
// Ensure email is provided
$email = $post_data[$this->email_id];
// $tmp = $_POST['lid'];
// if ($tmp != '') {$lid = $tmp; } //user may override default list ID
if ($email == '') {
echo('You must supply an email address');
return(0);
}
// 3) Login to phplist as admin and save cookie using CURLOPT_COOKIEFILE
// NOTE: Must log in as admin in order to bypass email confirmation
$url = $this->domain . "admin/";
$ch=curl_init();
if (curl_errno($ch)) {
print '<h3 style="color:red">Init Error: ' . curl_error($ch) .' Errno: '. curl_errno($ch) . "</h3>";
return(0);
}
$post_data='action=subscribe&group_ids[]
'.$this->lid.'&email_address='.$this->email_id.'&firstname='.$this->name_id;Is the $post_data line what I need? Something like this?:
function subscribe($input_data) {
// $post_data = array();
foreach ($input_data as $varname => $varvalue) {
$post_data[$varname] = $varvalue;
}
$email = $post_data[$this->email_id];
$name = $post_data[$this->name_id];
}And then I could use $email and $name in my function to “do stuff” with?
Or can I use $post_data[$this->email_id] etc. directly? Is that the simple answer to my original question?
Why is the $post_data commented out?! Don’t I need it?
Do I need other pieces to make it work? For which fields would this work; only those from wp_users or xprofile as well? What about custom fields, including the real name/first name/last name mess?
July 29, 2009 at 8:12 am #50240In reply to: custom members loop
lokers
Participantyes, but get_userdata() doesn’t return values like avatar and additional profile fields from registration. I found some functions in a core but I am not sure I should go that deep to get this info.
bp_core_get_userurl()
bp_core_get_avatar()
bp_core_get_userlink()
and finaly the best one:
xprofile_get_field_data()
July 29, 2009 at 3:29 am #50230In reply to: Gender Specific
r-a-y
KeymasterYou could use BuddyPress’ x-profile fields to create a required, custom radio button for gender.
The hard part will be hacking the activity feed to show the pronoun differential.
You’d have to create your own function similar to Buddypress’ bp_your_or_their() function.
Then apply that function as a filter on bp_activity_content_filter.
July 27, 2009 at 3:18 pm #50130Korhan Ekinci
Participantlike dateboxes? See this:
https://buddypress.org/forums/topic/datebox-problems-in-profiles
July 25, 2009 at 11:36 am #50013plrk
ParticipantI’m not sure what you want to do, but with this code, you can get a list of the options and the amount of users who have selected the option. Note: for selectbox and radio fields only.
$field_id = 1; // this should be the id of the
// field you want, see your wp_bp_xprofile_fields
// database table to find it
global $wpdb;
$sql = "SELECT value FROM {$wpdb->base_prefix}bp_xprofile_data WHERE field_id = {$field_id} ORDER BY id DESC";
$result = $wpdb->get_col($wpdb->prepare($sql));
foreach($result as $row){
if(strlen($row) > 0){
$values[$row]++;
}
}
$i = 0;
foreach($values as $key => $value){
$i++;
if($i != 1){
echo ", ";
}
echo $key . "(" . $value . ")";
}July 25, 2009 at 6:12 am #50008r-a-y
KeymasterAhh okay… forget my last post entirely then! haha.
Not sure if this will work at all…
$myxprofileFields = new BP_XProfile_ProfileData::get_value_byfieldname('Hair Color');
echo $myxprofileFields();This is where my knowledge of PHP stops here!
I’m not that great with classes and objects.
July 25, 2009 at 4:43 am #50006r-a-y
KeymasterHey Chris,
I’m assuming you’re using one of the prebuilt fields called “State”.
I didn’t look too closely at the classes or template tags, but check out /buddypress/bp-xprofile/bp-xprofile-classes.php.
There’s a function called “get_prebuilt_field_data()” that might help you out there.
You’d have to pass the CSV file to that function, but that might help…
Another way to output the “State” data would be to parse the actual CSV itself that is used for the data. The CSV can be found in buddypress/bp-xprofile/prebuilt-fields/states.csv.
Hope that helps somewhat!
July 23, 2009 at 7:37 pm #49929peterverkooijen
ParticipantThis plugin attempt doesn’t break anything, but still doesn’t put first_name and last_name in wp_usermeta either:
`
<?php
/*
Plugin Name: Real Name Synchro
Plugin URI: http://
Version: v0.001
Author: peterverkooijen
Description: A plugin to store firstname and lastname from the fullname field in Buddypress registration in WPMU usermeta tables.
*/
function real_name_synchro() {
global $bp, $wpdb, $bp_user_signup_meta;
$fields = BP_XProfile_Field::get_signup_fields();
if ( $fields ) {
foreach ( $fields as $field ) {
$value = $_POST[‘field_’ . $field->id];
}
}
$field->id = ‘1’;
$fullname = $value;
$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 ) );
}
//Actions
add_action(‘user_register’, ‘real_name_synchro’);
//Filters
?>`
Can anyone suggest fixes or am I fundamentally on the wrong track?
-
AuthorSearch Results