function updateSubscribe( $user_id, $posted_field_ids, $errors, $old_values, $new_values )
{
if ( empty( $errors ) )
{
echo "<pre>";
//print_r( $posted_field_ids );
echo "<br>user id: " . $user_id . "<br>";
echo "<b>Old values</b><br>";
print_r($old_values);
echo "<b>New values</b><br>";
print_r($new_values);
echo "</pre>";
}
die("END");
}
add_action('xprofile_updated_profile', 'updateSubscribe', 1, 5);
Showing posts with label buddypress. Show all posts
Showing posts with label buddypress. Show all posts
Thursday, November 9, 2017
Tuesday, October 10, 2017
custom URL change OR Re-write URL OR slug change for buudypress default slug
https://buddypress.org/2009/05/customizable-slugs-in-buddypress/
It’s actually as simple as defining the slugs you want to use in your wp-config.php file. All the slugs for every built in component can be changed. Here’s a list of settings you can add (with some alternate slugs already set), that will change the slugs for each component:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| define ( 'BP_ACTIVITY_SLUG' , 'streams' ); define ( 'BP_BLOGS_SLUG' , 'journals' ); define ( 'BP_MEMBERS_SLUG' , 'users' ); define ( 'BP_FRIENDS_SLUG' , 'peeps' ); define ( 'BP_GROUPS_SLUG' , 'gatherings' ); define ( 'BP_MESSAGES_SLUG' , 'notes' ); define ( 'BP_WIRE_SLUG' , 'pinboard' ); define ( 'BP_XPROFILE_SLUG' , 'info' ); /* Some other non-component slugs */ define ( 'BP_REGISTER_SLUG' , 'signup' ); define ( 'BP_ACTIVATION_SLUG' , 'enable' ); define ( 'BP_SEARCH_SLUG' , 'find' ); define ( 'BP_HOME_BLOG_SLUG' , 'news' ); |
Monday, August 21, 2017
custom activity in buddypress OR mentions add in activity feed
do_action( 'bp_before_directory_activity' );
do_action( 'bp_before_directory_activity_content' );
do_action( 'template_notices' );
$userIdd = bp_loggedin_user_id();
$sql = "SELECT leader_id, follower_id FROM wp_bp_follow WHERE follower_id=$userIdd OR leader_id = $userIdd";
$followers = $wpdb->get_col( $sql );
$friends_and_me = '&user_id=' . $followers;
$followers = array_unique($followers);
$followers[] = bp_loggedin_user_id();
$friends_and_me = implode( ',', (array) $followers );
$friends_and_me = '&user_id=' . $friends_and_me;
global $bp;
$bp->current_action = array('public');
if ( bp_has_activities( bp_ajax_querystring( 'activity' ) . $friends_and_me) ) :
while ( bp_activities() ) : bp_the_activity();
$activity_id = bp_get_activity_id();
if ( !empty( $activity_id ) ) {
$the_act_list .= $activity_id.',';
}
endwhile;
endif;
$bp->current_action = array('mentions');
if ( bp_has_activities( bp_ajax_querystring( 'activity' ) . $friends_and_me) ) :
while ( bp_activities() ) : bp_the_activity();
if ( !empty( bp_get_activity_id() ) ) {
$the_mention_act_list .= bp_get_activity_id().',';
}
endwhile;
endif;
$the_act_list = rtrim($the_act_list,',');
$the_mention_act_list = rtrim($the_mention_act_list,',');
$the_act_list = $the_act_list.','.$the_mention_act_list;
$activitlistttt = 'include='.$the_act_list.'&max=20';
if ( bp_has_activities( bp_ajax_querystring( 'activity' ) . $activitlistttt) ) :
while ( bp_activities() ) : bp_the_activity();
locate_template( array( 'buddypress/activity/entry.php' ), true, false );
endwhile;
endif;
do_action( 'bp_after_directory_activity_list' );
do_action( 'bp_directory_activity_content' );
do_action( 'bp_after_directory_activity_content' );
do_action( 'bp_after_directory_activity' );
Friday, June 23, 2017
Sunday, May 21, 2017
use user activity in custom template in buddypress
<?php
if($memberId == get_current_user_id()) {
locate_template( 'buddypress/activity/index.php',true );
}
?>
<?php
do_action( 'bp_before_directory_activity' );
do_action( 'bp_before_directory_activity_content' );
do_action( 'template_notices' );
?>
<?php if ( is_user_logged_in() ) : ?>
<?php if(bp_displayed_user_id() == get_current_user_id()){ ?>
<?php bp_get_template_part( 'buddypress/activity/post-form' ); ?>
<?php } ?>
<?php endif; ?>
<?php
global $wpdb;
$userIdd = bp_loggedin_user_id();
$sql = "SELECT leader_id FROM sf_bp_follow WHERE follower_id=$userIdd";
$followers = $wpdb->get_col( $sql );
$friends_and_me = '&user_id=' . $followers;
$followers = array_unique($followers);
$followers[] = bp_loggedin_user_id();
$friends_and_me = implode( ',', (array) $followers );
$friends_and_me = '&user_id=' . $friends_and_me;
?>
<?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ) . $friends_and_me) ) : ?>
<?php //if ( bp_has_activities( bp_ajax_querystring( 'activity' ) ) ) : ?>
<?php while ( bp_activities() ) : bp_the_activity(); ?>
<?php locate_template( array( 'buddypress/activity/entry.php' ), true, false ); ?>
<?php endwhile; ?>
<?php endif; ?>
<?php
/**
* Fires after the display of the activity list.
*
* @since 1.5.0
*/
do_action( 'bp_after_directory_activity_list' ); ?>
<?php
/**
* Fires inside and displays the activity directory display content.
*/
do_action( 'bp_directory_activity_content' ); ?>
<?php
/**
* Fires after the activity directory display content.
*
* @since 1.2.0
*/
do_action( 'bp_after_directory_activity_content' ); ?>
<?php
/**
* Fires after the activity directory listing.
*
* @since 1.5.0
*/
do_action( 'bp_after_directory_activity' ); ?>
if($memberId == get_current_user_id()) {
locate_template( 'buddypress/activity/index.php',true );
}
?>
<?php
do_action( 'bp_before_directory_activity' );
do_action( 'bp_before_directory_activity_content' );
do_action( 'template_notices' );
?>
<?php if ( is_user_logged_in() ) : ?>
<?php if(bp_displayed_user_id() == get_current_user_id()){ ?>
<?php bp_get_template_part( 'buddypress/activity/post-form' ); ?>
<?php } ?>
<?php endif; ?>
<?php
global $wpdb;
$userIdd = bp_loggedin_user_id();
$sql = "SELECT leader_id FROM sf_bp_follow WHERE follower_id=$userIdd";
$followers = $wpdb->get_col( $sql );
$friends_and_me = '&user_id=' . $followers;
$followers = array_unique($followers);
$followers[] = bp_loggedin_user_id();
$friends_and_me = implode( ',', (array) $followers );
$friends_and_me = '&user_id=' . $friends_and_me;
?>
<?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ) . $friends_and_me) ) : ?>
<?php //if ( bp_has_activities( bp_ajax_querystring( 'activity' ) ) ) : ?>
<?php while ( bp_activities() ) : bp_the_activity(); ?>
<?php locate_template( array( 'buddypress/activity/entry.php' ), true, false ); ?>
<?php endwhile; ?>
<?php endif; ?>
<?php
/**
* Fires after the display of the activity list.
*
* @since 1.5.0
*/
do_action( 'bp_after_directory_activity_list' ); ?>
<?php
/**
* Fires inside and displays the activity directory display content.
*/
do_action( 'bp_directory_activity_content' ); ?>
<?php
/**
* Fires after the activity directory display content.
*
* @since 1.2.0
*/
do_action( 'bp_after_directory_activity_content' ); ?>
<?php
/**
* Fires after the activity directory listing.
*
* @since 1.5.0
*/
do_action( 'bp_after_directory_activity' ); ?>
Wednesday, April 19, 2017
Get current logged in user details in buddypress OR get profile field data for loggin user
//get login user sex
global $bp;
$the_user_id = $bp->loggedin_user->userdata->ID;
$loginUserSex = bp_get_profile_field_data( 'field=sex&user_id=' . $the_user_id );
global $bp;
$the_user_id = $bp->loggedin_user->userdata->ID;
$loginUserSex = bp_get_profile_field_data( 'field=sex&user_id=' . $the_user_id );
Friday, March 24, 2017
add a friends disable in buddypress
/* Add friend functionality disable in buddypress
================================================== */
add_filter('bp_get_add_friend_button', '__return_false');
Tuesday, March 14, 2017
Change the Default Avatar for Members in BuddyPress
function myavatar_add_default_avatar( $url )
{
return get_template_directory_uri().'/images/event.png';
}
add_filter( 'bp_core_mysteryman_src', 'myavatar_add_default_avatar' );
function my_default_get_group_avatar($avatar) {
global $bp, $groups_template;
if( strpos($avatar,'group-avatars') ) {
return $avatar;
}
else {
$custom_avatar = get_template_directory_uri() .'/images/event.png';
if($bp->current_action == "")
return '<img class="avatar" alt="' . attribute_escape( $groups_template->group->name ) . '" src="'.$custom_avatar.'" width="'.BP_AVATAR_THUMB_WIDTH.'" height="'.BP_AVATAR_THUMB_HEIGHT.'" />';
else
return '<img class="avatar" alt="' . attribute_escape( $groups_template->group->name ) . '" src="'.$custom_avatar.'" width="'.BP_AVATAR_FULL_WIDTH.'" height="'.BP_AVATAR_FULL_HEIGHT.'" />';
}
}
add_filter( 'bp_get_group_avatar', 'my_default_get_group_avatar');
set profile data for a specific field for a specific user. OR update user extend profile fields
http://buddypress.wp-a2z.org/oik_api/xprofile_set_field_data/
$interest = isset($_POST['interest'])?$_POST['interest']:''; //value
$field = 'Interest'; // field name
$field_id = xprofile_get_field_id_from_name( $field );
$field = new BP_XProfile_ProfileData();
$field->field_id = $field_id;
$field->user_id = $user_id;
$field->value = maybe_serialize( $interest );
$field->save();
$interest = isset($_POST['interest'])?$_POST['interest']:''; //value
$field = 'Interest'; // field name
$field_id = xprofile_get_field_id_from_name( $field );
$field = new BP_XProfile_ProfileData();
$field->field_id = $field_id;
$field->user_id = $user_id;
$field->value = maybe_serialize( $interest );
$field->save();
function xprofile_set_field_data( $field, $user_id, $value, $is_required = false ) { if ( is_numeric( $field ) ) { $field_id = $field; } else { $field_id = xprofile_get_field_id_from_name( $field ); } if ( empty( $field_id ) ) { return false; } $field = xprofile_get_field( $field_id ); $field_type = BP_XProfile_Field::get_type( $field_id ); $field_type_obj = bp_xprofile_create_field_type( $field_type ); /** * Filter the raw submitted profile field value. * * Use this filter to modify the values submitted by users before * doing field-type-specific validation. * * @since 2.1.0 * * @param mixed $value Value passed to xprofile_set_field_data(). * @param BP_XProfile_Field $field Field object. * @param BP_XProfile_Field_Type $field_type_obj Field type object. */ $value = apply_filters( 'bp_xprofile_set_field_data_pre_validate', $value, $field, $field_type_obj ); // Special-case support for integer 0 for the number field type. if ( $is_required && ! is_integer( $value ) && $value !== '0' && ( empty( $value ) || ! is_array( $value ) && ! strlen( trim( $value ) ) ) ) { return false; } /** * Certain types of fields (checkboxes, multiselects) may come through empty. * Save as empty array so this isn't overwritten by the default on next edit. * * Special-case support for integer 0 for the number field type */ if ( empty( $value ) && ! is_integer( $value ) && $value !== '0' && $field_type_obj->accepts_null_value ) { $value = array(); } // If the value is empty, then delete any field data that exists, unless the field is of a type // where null values are semantically meaningful. if ( empty( $value ) && ! is_integer( $value ) && $value !== '0' && ! $field_type_obj->accepts_null_value ) { xprofile_delete_field_data( $field_id, $user_id ); return true; } // For certain fields, only certain parameters are acceptable, so add them to the whitelist. if ( $field_type_obj->supports_options ) { $field_type_obj->set_whitelist_values( wp_list_pluck( $field->get_children(), 'name' ) ); } // Check the value is in an accepted format for this form field. if ( ! $field_type_obj->is_valid( $value ) ) { return false; } $field = new BP_XProfile_ProfileData(); $field->field_id = $field_id; $field->user_id = $user_id; $field->value = maybe_serialize( $value ); return $field->save(); }
Subscribe to:
Posts (Atom)