Search Results for 'group_id'
-
AuthorSearch Results
-
January 2, 2010 at 7:21 pm #59912
In reply to: Move profile fields to another field group?
Anonymous User 96400
InactiveJust had a quick look. You might be able to just get away with changing the group_id field in wp_bp_xprofile_fields to the id of the new group. The data table only seems to be looking for the id field. You can do that in phpMyAdmin. Try it locally, though, first if at all possible.
January 1, 2010 at 7:42 pm #59885In reply to: Soon to release bp group control plugin
Anonymous User 96400
Inactivesetting up different group types is fairly easy. You just have to attach some groupmeta to the group, that basically let you add as many types as you’d like. Then you just check the metadata to figure out what type of group you’re in. Using the groups API you can then add different functionality for different groups.
I’ve written a types-plugin for one of my sites. It doesn’t have an interface, though. The 3 types I needed are hardcoded into it, so it’s really not suited for a release at the moment. There’s also a lot of more stuff, like a shopping cart, part of that plugin. So, I’ve stripped the functions needed for group types out (hopefully al of them).
First we need to add the addtional fields to our registration form:
function sv_add_registration_group_types()
{
?>
<div id="account-type" class="register-section">
<h3 class="transform"><?php _e( 'Choose your account type (required)', 'group-types' ) ?></h3>
<script type="text/javascript" defer="defer">
jQuery(document).ready(function(){
jQuery("#account-type-normal_user").attr("checked", true);
jQuery("#group-details").hide();
jQuery("#account-type-type_one,#account-type-type_two,#account-type-type_three").click(function(){
if (jQuery(this).is(":checked")) {
jQuery("#group-details").slideDown("slow");
} else {
jQuery("#group-details").slideUp("slow");
}
});
jQuery("#account-type-normal_user").click(function(){
if (jQuery(this).is(":checked")) {
jQuery("#group-details").slideUp("slow");
} else {
jQuery("#group-details").slideDown("slow");
}
});
});
</script>
<?php do_action( 'bp_account_type_errors' ) ?>
<label><input type="radio" name="account_type" id="account-type-normal_user" value="normal_user" checked="checked" /><?php _e( 'User', 'group-types' ) ?></label>
<label><input type="radio" name="account_type" id="account-type-type_one" value="type_one" /><?php _e( 'Type 1', 'group-types' ) ?></label>
<label><input type="radio" name="account_type" id="account-type-type_two" value="type_two" /><?php _e( 'Type 2', 'group-types' ) ?></label>
<label><input type="radio" name="account_type" id="account-type-type_three" value="type_three" /><?php _e( 'Type 3', 'group-types' ) ?></label>
<div id="group-details">
<p><?php _e( 'We will automatically create a group for your business or organization. This group will be tailored to your needs! You can change the description and the news later in the admin section of your group.', 'group-types' ); ?></p>
<?php do_action( 'bp_group_name_errors' ) ?>
<label for="group_name"><?php _e( 'Group Name', 'scuba' ) ?> <?php _e( '(required)', 'buddypress' ) ?></label>
<input type="text" name="group_name" id="group_name" value="" />
<br /><small><?php _e( 'We suggest you use the name of your business or organization', 'group-types' ) ?></small>
<label for="group_desc"><?php _e( 'Group Description', 'scuba' ) ?></label>
<textarea rows="5" cols="40" name="group_desc" id="group_desc"></textarea>
<br /><small><?php _e( 'This description will be visible on your group profile, so it could be used to present your mission statement for example.', 'group-types' ) ?></small>
<label for="group_news"><?php _e( 'Group News', 'scuba' ) ?></label>
<textarea rows="5" cols="40" name="group_news" id="group_news"></textarea>
<br /><small><?php _e( 'Enter any news that you want potential members to see.', 'group-types' ) ?></small>
</div>
</div>
<?php
}
add_action( 'bp_before_registration_submit_buttons', 'sv_add_registration_group_types' );Then we have to validate things and add some usermeta when a regitration happens:
/**
* Add custom userdata from register.php
* @since 1.0
*/
function sv_add_to_signup( $usermeta )
{
$usermeta['account_type'] = $_POST['account_type'];
if( isset( $_POST['group_name'] ) )
$usermeta['group_name'] = $_POST['group_name'];
if( isset( $_POST['group_desc'] ) )
$usermeta['group_desc'] = $_POST['group_desc'];
if( isset( $_POST['group_news'] ) )
$usermeta['group_news'] = $_POST['group_news'];
return $usermeta;
}
add_filter( 'bp_signup_usermeta', 'sv_add_to_signup' );
/**
* Update usermeta with custom registration data
* @since 1.0
*/
function sv_user_activate_fields( $user )
{
update_usermeta( $user['user_id'], 'account_type', $user['meta']['account_type'] );
if( isset( $user['meta']['group_name'] ) )
update_usermeta( $user['user_id'], 'group_name', $user['meta']['group_name'] );
if( isset( $user['meta']['group_desc'] ) )
update_usermeta( $user['user_id'], 'group_desc', $user['meta']['group_desc'] );
if( isset( $user['meta']['group_news'] ) )
update_usermeta( $user['user_id'], 'group_news', $user['meta']['group_news'] );
return $user;
}
add_filter( 'bp_core_activate_account', 'sv_user_activate_fields' );
/**
* Perform checks for custom registration data
* @since 1.0
*/
function sv_check_additional_signup()
{
global $bp;
if( empty( $_POST['account_type'] ) )
$bp->signup->errors['account_type'] = __( 'You need to choose your account type', 'group-types' );
if( empty( $_POST['group_name'] ) && $_POST['account_type'] != 'normal_user' )
$bp->signup->errors['group_name'] = __( 'You need to pick a group name', 'group-types' );
if( ! empty( $_POST['group_name'] ) && $_POST['account_type'] != 'normal_user' )
{
$slug = sanitize_title_with_dashes( $_POST['group_name'] );
$exist = groups_check_group_exists( $slug );
if( $exist )
$bp->signup->errors['group_name'] = __( 'This name is not available. If you feel this is a mistake, please <a href="/contact">contact us</a>.', 'group-types' );
}
}
add_action( 'bp_signup_validate', 'sv_check_additional_signup' );And then we set up the group for the user (there are some constants in this function, so you’ll need to change that):
/**
* Create custom groups for skools, biz and org accounts
* @since 1.0
*/
function sv_init_special_groups( $user )
{
global $bp;
// get account type
$type = get_usermeta( $user['user_id'], 'account_type' );
if( $type == 'normal_user' )
{
// Do nothing
}
elseif( $type == 'type_one' || $type == 'type_two' || $type == 'type_three' )
{
// get some more data from sign up
$group_name = get_usermeta( $user['user_id'], 'group_name' );
$group_desc = get_usermeta( $user['user_id'], 'group_desc' );
$group_news = get_usermeta( $user['user_id'], 'group_news' );
$slug = sanitize_title_with_dashes( $group_name );
// create dive skool group
$group_id = groups_create_group( array(
'creator_id' => $user['user_id'],
'name' => $group_name,
'slug' => $slug,
'description' => $group_desc,
'news' => $group_news,
'status' => 'public',
'enable_wire' => true,
'enable_forum' => true,
'date_created' => gmdate('Y-m-d H:i:s')
)
);
// add the type to our group
groups_update_groupmeta( $group_id, 'group_type', $type );
// delete now useless data
delete_usermeta( $user['user_id'], 'group_name' );
delete_usermeta( $user['user_id'], 'group_desc' );
delete_usermeta( $user['user_id'], 'group_news' );
// include PHPMailer
require_once( SV_MAILER . 'class.phpmailer.php' );
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = SV_SMTP;
$auth = get_userdata( $user['user_id'] );
$profile_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $slug . '/admin';
$message = sprintf( __( 'Hello %s,
we have created a group for your business or organization. To get more out of your presence on Yoursitenamehere please take some time to set it up properly.
Please follow this link to fill in the rest of your profile: %s
We wish you all the best. Should you have any questions regarding your new group, please contact us at support@yoursitenamehere.com.
Your Yoursitenamehere Team', 'group-types' ), $auth->display_name, $profile_link );
$mail->SetFrom("support@yoursitenamehere.com","Yoursitenamehere");
$mail->AddAddress( $auth->user_email );
$mail->Subject = __( 'Your new group pages on Yoursitenamehere', 'group-types' );
$mail->Body = $message;
$mail->WordWrap = 75;
$mail->Send();
}
}
add_action( 'bp_core_account_activated', 'sv_init_special_groups' );When you write a group extension we’ll have to swap the activation call with a function like the one below to be able to check for group types.
/**
* Replacement activation function for group extension classes
*/
function activate_type_one()
{
global $bp;
$type = groups_get_groupmeta( $bp->groups->current_group->id, 'group_type' );
if( $type == 'type_one' )
{
$extension = new Group_Type_One;
add_action( "wp", array( &$extension, "_register" ), 2 );
}
}
add_action( 'plugins_loaded', 'activate_type_one' );The last thing we need to do is add our group type names to group and directory pages:
/**
* Modify the group type status
*/
function sv_get_group_type( $type, $group = false )
{
global $groups_template;
if( ! $group )
$group =& $groups_template->group;
$gtype = groups_get_groupmeta( $group->id, 'group_type' );
if( $gtype == 'type_one' )
$name = __( 'Type 1', 'group-types' );
elseif( $gtype == 'type_two' )
$name = __( 'Type 2', 'group-types' );
elseif( $gtype == 'type_three' )
$name = __( 'Type 3', 'group-types' );
else
$name = __( 'User Group', 'group-types' );
if( 'public' == $group->status )
{
$type = sprintf( __( "%s (public)", "group-types" ), $name );
}
elseif( 'hidden' == $group->status )
{
$type = sprintf( __( "%s (hidden)", "group-types" ), $name );
}
elseif( 'private' == $group->status )
{
$type = sprintf( __( "%s (private)", "group-types" ), $name );
}
else
{
$type = ucwords( $group->status ) . ' ' . __( 'Group', 'buddypress' );
}
return $type;
}
add_filter( 'bp_get_group_type', 'sv_get_group_type' );
/**
* Modify the group type status on directory pages
*/
function sv_get_the_site_group_type()
{
global $site_groups_template;
return sv_get_group_type( '', $site_groups_template->group );
}
add_filter( 'bp_get_the_site_group_type', 'sv_get_the_site_group_type' );It’s quite a bit of code, but it should get you started. This hasn’t been tested with 1.2 btw.
December 14, 2009 at 7:35 am #58673In reply to: Restricting group creation to admins
vusis
Participanthey guys i cant seem to figure this one out hey; i’ve tried to patch the bp-groups.php file but i get a
#1 HUNK Failed at 449 – please see my reject file
***************
*** 453,459 ****
bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . ‘/create/step/’ . $bp->groups->current_create_step );
}
– if ( !$bp->groups->new_group_id = groups_create_group( array( ‘group_id’ => $bp->groups->new_group_id, ‘name’ => $_POST[‘group-name’], ‘description’ => $_POST[‘group-desc’], ‘news’ => $_POST[‘group-news’], ‘slug’ => groups_check_slug( sanitize_title($_POST[‘group-name’]) ), ‘date_created’ => time() ) ) ) {
bp_core_add_message( __( ‘There was an error saving group details, please try again.’, ‘buddypress’ ), ‘error’ );
bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . ‘/create/step/’ . $bp->groups->current_create_step );
}
— 453,474 —-
bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . ‘/create/step/’ . $bp->groups->current_create_step );
}
+ $group_details = array(
+ ‘group_id’ => $bp->groups->new_group_id,
+ ‘name’ => $_POST[‘group-name’],
+ ‘description’ => $_POST[‘group-desc’],
+ ‘news’ => $_POST[‘group-news’],
+ ‘slug’ => groups_check_slug( sanitize_title($_POST[‘group-name’]) ),
+ ‘date_created’ => time() );
+
+ /* Allow plugins to halt group creation for whatever reason. On doing this the plugin
+ should use the bp_core_add_message function to inform the user why the group creation
+ has failed.
+ N.B. The data passed in $new_group is unsanitised. */
+ if ( ! apply_filters( ‘bp_allow_create_group’, true, $group_details ) )
+ return bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . ‘/create’ );
+
+ if ( !$bp->groups->new_group_id = groups_create_group( $group_details ) ) {
bp_core_add_message( __( ‘There was an error saving group details, please try again.’, ‘buddypress’ ), ‘error’ );
bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . ‘/create/step/’ . $bp->groups->current_create_step );
}
i’m not too sure what that means and how it can be fixed?
December 2, 2009 at 9:35 pm #57918In reply to: Extending Group Creation
Andy Peatling
KeymasterYou should make it a plugin, then add this to the plugin and activate. If you’d like to see a working implementation then check out these plugins:
https://wordpress.org/extend/plugins/buddypress-group-twitter
https://wordpress.org/extend/plugins/bp-groupblog
https://wordpress.org/extend/plugins/external-group-blogs
You should be saving extra group information as groupmeta:
bp_groups_update_groupmeta( $group_id, 'name', $value );November 30, 2009 at 9:31 pm #57761In reply to: Get Group_ID from Group Name?
Andy Peatling
Keymaster$group_id = BP_Groups_Group::group_exists($group_slug)Not technically named for what you want to do, but it does the job. I will add a better named function for this.
November 17, 2009 at 10:02 pm #56897In reply to: All fields for registration
Philipp
ParticipantHi and thanks al lot for you answers!
So it’s not enoght to change the code like this:
<?php if ( function_exists( ‘bp_has_profile’ ) ) : if ( bp_has_profile( ‘profile_group_id=2’ ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
Shall I write:
<input type=”hidden” name=”signup_profile_field_ids” id=”signup_profile_field_ids” value=”<?php echo $all_pf_fields;?>” />
or:
<input type=”hidden” name=”signup_profile_field_ids” id=”signup_profile_field_ids” value=”1,2,3,4,5″ />
I’m very sorry, but I didn’t get what you mean with the Profileloop. It would be so glad if you could write what to change or to ad excactly…
Thanks a lot!
Philipp
November 17, 2009 at 5:13 pm #56867In reply to: All fields for registration
Brajesh Singh
Participanthi Phillip
Yes yo can.
By default your registration page will show only the fields from first profile field group.
You can change it.
You will have to edit registration/register.php
Look for the code
bp_has_profile( 'profile_group_id=1' )
and replace it with
bp_has_profile( )
Now your register page will show all the fields.
But stop,This is not enough,you need to aggregate all the field ids and put it as hidden field.
So Take a look at the the line
<input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_group_field_ids() ?>" />
remove it from the profile loop.Now create some code inside the profile loop,aggregate all profile ids and then
put this code outside the profile group loop,
where I ssume you have aggregated all profile fields in the variable $all_pf_fields.
<input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php echo $all_pf_fields;?>" />
Please note,all $all_pf_fields should be the comma separated list of all profile ids(say 1,2,3,)
This will make it work,and your registration page will show all profile groups fields
November 17, 2009 at 5:06 pm #56866In reply to: All fields for registration
Simon Dabkowski
ParticipantEach field group has an ID value. You can modify the registration.php file to include additional groups by repeating the following and changing “1” to “2”:
<?php if ( function_exists( ‘bp_has_profile’ ) ) : if ( bp_has_profile( ‘profile_group_id=1’ ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
to
<?php if ( function_exists( ‘bp_has_profile’ ) ) : if ( bp_has_profile( ‘profile_group_id=2’ ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
November 7, 2009 at 11:15 am #56130In reply to: How to display avatars in normal theme at 125px?
Sven Lehnert
ParticipantIn the moment, I do what Andy has offered above.
Members:
<?php echo bp_core_fetch_avatar(
'item_id=' . get_the_author_id() . '&type=full&width=100&height=100' ) ?>Groups:
<?php echo bp_core_fetch_avatar( 'item_id=' . bp_get_the_site_group_id()
. '&object=group&type=full&width=100&height=100' ) ?>Just I think this is the same as doing it in the css.
I like to know how to change the original size at the moment when its created.
But I don’t want to define these with custom values in wp-config.php.
I’m looking for a solution to have control of the Avatar size in custom components.
for example: In the bp-events Plugin, I would like to change the Avatar format to a Flyer format.
Most of the Event Flyer, people want to upload, do not feed the Avatar size from Buddypress.
So they just get a cuted piece of there flayer.
I relay would like to change this.
November 1, 2009 at 8:24 am #55584In reply to: Unable to create groups or forums
John James Jacoby
KeymasterOdd, because in order for the avatar to upload correctly, it needs to be created by being provided a group_id. Is your avatar uploaded and displayed correctly? Technically the group is created after the first step, and the subsequent steps only serve to fill in the settings and options.
October 30, 2009 at 3:58 am #55454In reply to: accessing the item_id with bpcontents
dpolant
ParticipantI don’t think there is a bpcontents template tag that outputs an item id in the loop.
I assume you’re trying to access this value in a place where $oci_items_template has been defined, and so I think the fastest way to get it is to call global $oci_items_template and then get $oci_items_template->item->id.
If on the off chance you have a group_id or user_id to feed in, oci_get_member_item_id() and oci_get_group_item_id() will return (not output) an item id from a group or user id. That’s about the best I can do but I bet that’s not what you’re looking for.
So like you said, you’re probably going to want to write your own template tag to do this.
I tried to contact Burt about a month ago and haven’t heard back yet – I heard he might be working on a new version of bpcontents but I don’t know anything definite.
One word of warning – at least in my case, the 1.1 upgrade totally broke down bpcontents. It wasn’t too hard to get it working again but required about half a day of debugging. If you’ve got bpcontents running in 1.1 + without hacks I’d be very interested to hear how you did it.
October 11, 2009 at 4:26 pm #54337In reply to: Removing Profile Field Links
Paul Wong-Gibbs
KeymasterAloha. You can use this for starters:
function df_xprofile_filter_link_profile_data( $field_value, $field_type = 'textbox' ) {
global $bp, $field;
remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 2, 2 );
if ( 1 == $field->group_id && 'Name' == $field->name )
return 'change this to whatever you want';
else
return xprofile_filter_link_profile_data( $field_value, $field_type );
}
add_filter( 'bp_get_the_profile_field_value', 'df_xprofile_filter_link_profile_data', 1, 2 );This is edited from what I’m using for so not guaranteed to work first time.
October 5, 2009 at 1:39 am #53827Peter Kirn
ParticipantHi John – thanks for the detailed response. I did read the documentation. The problem is – and I didn’t realize this until after my first attempt at the upgrade was finished – that documentation doesn’t appear to cover the scenario of an existing, integrated bbPress setup with bbPress stored in a *different* database. So, initially, I tried to choose the existing installation. When that didn’t work, I went back into admin and chose the option that allows you to try again with a fresh installation. What I’m trying to fix now is a *new* bbPress installation – but with existing groups.
Certainly, what you describe makes absolute sense. So now, I’m just looking for a resolution. I’m not concerned about existing forum posts; I think we can start fresh.
I’m looking now at the database. In wp_bp_groups_groupmeta, I see id and group_id.
In wp_bp_groups, I see id and enable_forum.
But enable_forum is the boolean for that checkbox. I don’t see where the forum_id is stored; it’s not listed as a field in either of those tables. Do I need to look at the bbpress table? How is the forum id matched up with the group id, since that seems to be the issue? Presumably if I delete the fields for that metadata, then disable the forum option for each of the groups, then re-enable, it should create new forums, yes? But where do I find that forum ID metadata, or can I actually simply delete the metadata for each of the groups that has a forum?
October 4, 2009 at 11:50 pm #53820John James Jacoby
KeymasterI recommend reading https://codex.buddypress.org/developer-discussions/buddypress-forum/ if you haven’t already…
Peterkirn, did you choose a new installation or an existing one when you updated?
Here’s what’s happening, and how to fix it.
Since you picked new installation, your existing groups forums won’t work, because the forum_id’s they want to post to don’t exist in your new installation.
Basically, New installation = New database tables
If your old forums don’t have any important or relevent topics, or any at all, go back and forth between your “wp_bp_groups” table and your “wp_bp_groups_groupmeta” table, and remove the groupmeta entries with the group_id’s of your existing groups, that have any forum_id.
When you disable and enable the forums, it isn’t creating a new forum for them, it’s just turning off the ability. If you created a forum for an old group, and then create a new installation, the new database tables will be empty and your BuddyPress forums will look at those tables for data. If you use an existing installation, then BuddyPress will continue to use the old bbPress tables and allow an external bbPress installation to access them on its own, while letting the bbPress included with BuddyPress use it for its own purposes.
September 17, 2009 at 6:44 pm #52669In reply to: Group activity displaying other group activity
Andy Peatling
KeymasterOk the problem is retroactive. Before recent versions, group wire posts were recording the wire_post_id as the primary ID in the activity stream, and not the group_id. This means the filter is picking up wire posts with the same ID as the new group.
There is really no way to fix this, it will not happen moving forward. Your best bet is to delete any activity that is not correct. It should be rare, and very limited – only one item in most cases.
August 23, 2009 at 3:41 pm #51446In reply to: ListMessenger (or PHPlist) integration – plugin?
peterverkooijen
ParticipantThis works:
function synchro_mailinglist($user_id, $password, $meta) {
global $bp, $wpdb;
$email = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE ID='$user_id'");
$fullname = $meta[field_1];
$space = strpos( $fullname, ' ' );
$company = $meta[field_2];
if ( false === $space ) {
$firstname = $fullname;
$lastname = '';
} else {
$firstname = substr( $fullname, 0, $space );
$lastname = trim( substr( $fullname, $space, strlen($fullname) ) );
}
$firstname = nameize($firstname);
$lastname = nameize($lastname);
...
$wpdb->query("INSERT mailingusers SET users_id='$user_id', group_id='1', signup_date= UNIX_TIMESTAMP(), firstname= '$firstname', lastname= '$lastname', email_address = '$email' ");
$wpdb->query("INSERT mailingcdata SET cdata_id=NULL, user_id='$user_id', cfield_id='1', value='$company'");
}
add_action( 'wpmu_activate_user', 'synchro_mailinglist', 10, 3);I used it as part of this function. This should work other mailinglist scripts as well, just change the table and field names.
I don’t understand why $user_email didn’t work. I had to pull the user_email from the database. Is there a cleaner way?
August 22, 2009 at 2:22 pm #51411In reply to: ListMessenger (or PHPlist) integration – plugin?
peterverkooijen
ParticipantI’m now trying to add firstname, lastname and email address straight to the database tables of my mailing list. I’ve added the queries to the function I had put together here:
function synchro_wp_usermeta($user_id, $password, $meta) {
global $bp, $wpdb;
...
$wpdb->query("INSERT mailingusers SET users_id='$user_id', group_id='1', signup_date= UNIX_TIMESTAMP(), firstname= '$firstname', lastname= '$lastname', email_address= '$user_email'");
$wpdb->query("INSERT mailingcdata SET cdata_id=NULL, user_id='$user_id', cfield_id='1', value='$company'");
}
add_action( 'wpmu_activate_user', 'synchro_wp_usermeta', 10, 3);This mostly works, except the for the email address. $firstname, $lastname and $user_id are all correctly added to the table, but the email_address field stays empty.
Can anyone spot the problem?
How can I “call” the user’s email address upon ‘wpmu_activate_user’?
Adding a $user_email argument only produces missing argument errors. I’m out of guesses…
$current_user->user_email doesn’t work either:
$wpdb->query("INSERT mailingusers SET users_id='$user_id', group_id='1', signup_date= UNIX_TIMESTAMP(), firstname= '$firstname', lastname= '$lastname', email_address= '$current_user->user_email'");August 17, 2009 at 6:40 pm #51172In reply to: Signatures (BBPress & BuddyPress)
gerikg
ParticipantSorry 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?
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 13, 2009 at 10:40 pm #50989peterverkooijen
ParticipantAnother 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?
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?
chrisknade
ParticipantRight to clarify abit more this is what I have so far.
<?php echo the_title(); ?>
<?php if ( bp_has_groups( 'type=single-group&slug=USA' ) ) : ?>
<div class="pagination-links" id="group-count">
<?php bp_group_pagination_count() ?>
</div>
<div class="pagination-links" id="group-pag">
<?php bp_group_pagination() ?>
</div>
<ul id="group-list">
<?php while ( bp_groups() ) : bp_the_group(); ?>
<li>
<!-- Example template tags you can use -->
<?php bp_group_avatar_thumb() ?>
<?php $group_Id_Featured = bp_group_id() ?>
<?php bp_group_permalink() ?>
<?php bp_group_name() ?>
<?php bp_group_total_members() ?>
<?php bp_group_description_excerpt() ?>
</li>
<?php endwhile; ?>
</ul>
<?php else: ?>
<div id="message" class="info">
<p>There are no groups to display.</p>
</div>
<?php endif; ?>
<?php if ( bp_group_has_members('group_id=2&per_page=8') ) : ?>
<div id="member-count" class="pag-count">
<?php bp_group_member_pagination_count() ?>
</div>
<div id="member-pagination" class="pagination-links">
<?php bp_group_member_pagination() ?>
</div>
<ul id="member-list" class="item-list">
<?php while ( bp_group_members() ) : bp_group_the_member(); ?>
<li>
<!-- Example template tags you can use -->
<?php bp_group_member_avatar() ?>
<?php bp_group_member_link() ?>
<?php bp_group_member_joined_since() ?>
</li>
<?php endwhile; ?>
</ul>
<?php else: ?>
<div id="message" class="info">
<p>This group has no members.</p>
</div>
<?php endif;?>As you can see I’ve got <?php $group_Id_Featured = bp_group_id() ?> in there.
Im trying to say if
<?php if ( bp_group_has_members(‘group_id=2&per_page=8’) ) : ?> and use group_id=$group_Id_Featured . Anyone have any idea for the syntax for that. Tried loads of different variations none of which work.
July 15, 2009 at 7:22 am #49346In reply to: New Groupblog Plugin
Mariusooms
ParticipantGood idea r-a-y! It is summer vacation now, but I will definitely include some as our users start building their profile and groups with this plugin. These are some upcoming feautures:
* Construct the group_id, this allows us to switch blogs in the group and pull in the relevant information. (done)
* Construct the reverse blog_id, this allows us to have group based loops in the blog to display members, profile, activity etc based on the group id. (done)
* Allow blog registration at group sign up, much like how you can create a blog at site registration.
* Add members silently to the blog when they become group members.
* Different role caps depending on role within the group. By default members are authors, mods are editors and admins are admins.
* Allow the admin set role caps on group roles, e.g. the group admin only want its members to be subscribers. Or editors for a wiki type solution.
* Have an option to disable silent adding of members in case the group admin only wants (or needs) the group blog be accessible by him (or her).
* Create more templates. One we have now is a simple template that creates a menu from the page titles, which allows the group to behave like a cms.
We will also offer some blog templates to help make the blog look transparent to the information you display within the group so its transition from group to blog nad vice versa is seemless.
Thanks for your interests already.
June 28, 2009 at 1:04 am #48193In reply to: Profile Data On A Member Directory
Treblamah
ParticipantThanks. I ended up just switching the Group ID on the field I wanted to separate and called that profile group where I wanted the field to appear. I reproduced the profile loop in the index.php file for the user profile twice, once calling group 1 and the other, group 3.
<?php if ( bp_has_profile('profile_group_id=3') ) : ?>June 26, 2009 at 6:26 pm #48133In reply to: Profile Data On A Member Directory
landykos
ParticipantI just did a query on the members table then did a for each on the results. and for each group run the buddypress function:
global $wpdb;
$groups = $wpdb->get_results(“SELECT * FROM wp_bp_groups order by name”, ARRAY_A);
foreach ($groups as $group) :
bp_group_has_members(‘group_id=’.$group[‘id’].’&exclude_admins_mods=false’)
Then $group[‘name’] will get you the members name.
Hope that helps you!
LK
-
AuthorSearch Results