Replies
Hi Saad,
How do you add user as friend on your site. I created a new user and tried to add him as a friend to test the issue but, I was not able to accept my friendship request from other account. Please let me know how can I add friend
Thank You
Ravi- Ravi on April 5, 2016 at 12:07 pm in reply to: [Resolved] Blog Categories For Groups and Custom Taxonomies #3346
Hi Ada,
Brajesh sir is away now. He will get back to you soon.
Thank You
Ravi Hi Saad,
Thank you for sharing the details. I am looking into it and will update you at day end
Thank You
RaviHi Saad,
Welcome to BuddyDev forums.Can you please point me to your site and provide a temporary guest user account? I can quickly check and provide a fix.
Thank you
RaviHi Leo,
Thank you for confirming. I am glad that i could help
Hi Leo,
I have done some modification to the code. Please check it now
function buudydev_post_form() { $settings = array( 'post_type' => 'post', 'post_author' => bp_loggedin_user_id(), 'post_status' => 'publish', 'tax' => array( 'category' => array( 'include' => array( 61 ), //category ids 'view_type' => 'checkbox', ) ), 'current_user_can_post' => is_user_logged_in(), 'show_categories' => true, 'allow_upload' => true ); bp_new_simple_blog_post_form( 'my_custom_form', $settings ); } add_action( 'bp_init', 'buudydev_post_form', 4 ); //to show form bp_get_simple_blog_post_form('my_custom_form')->show();
Thank You
Ravi- This reply was modified 8 years, 8 months ago by Ravi.
Hi Leo,
Thank You for posting. I am looking into this issue and will update you shortly.
Thank You
RaviHi Mathew,
Thank You for posting. Yes, It is doable using wpulike plugin and little amount of code. Please see this post for details.
Hope that helps.
Thank You
Ravi- Ravi on April 2, 2016 at 6:16 pm in reply to: [Resolved] Add a User to a perticular group when User account is activated #3308
Hi Dandy,
Thank You for the acknowledgement. Yes in same way we can add friend to particular user.
function buddydev_add_as_friend_to_user( $user_id ) { $friend_userid = 2; //replace by your user id friends_add_friend( $user_id, $friend_userid, true ); } add_action( 'user_register', 'buddydev_add_as_friend_to_user', 0 );
Thank You
Ravi- This reply was modified 8 years, 8 months ago by Ravi.
Hi Saran,
Here is the the following code to implement your requirement you just need to put this code in your bp-custom.php file
function buddydev_modify_user_profile_tab() { $bp = buddypress(); bp_core_remove_subnav_item( $bp->settings->slug, 'general' ); bp_core_new_nav_default(array('parent_slug'=>$bp->settings->slug, 'subnav_slug' => 'notifications', 'screen_function'=> 'bp_settings_screen_notification')); $user_url = bp_loggedin_user_domain(); // add 'Change profile picture' sub-menu tab bp_core_new_subnav_item( array( 'name' => 'General', 'slug' => 'general', 'parent_url' => trailingslashit( $user_url . $bp->profile->slug ), 'parent_slug' => $bp->profile->slug, 'screen_function' => 'buddydev_screen_profile_general', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) ); } add_action( 'bp_setup_nav', 'buddydev_modify_user_profile_tab', 100 ); function buddydev_screen_profile_general() { bp_core_load_template( 'members/single/settings/general' ); } function buddydev_profile_general_save() { // Bail if not a POST action. if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) return; // Bail if no submit action. if ( ! isset( $_POST['submit'] ) ) return; // Bail if not in settings. if ( ! bp_is_profile_component() && ! bp_is_current_action( 'general' ) ) return; // 404 if there are any additional action variables attached if ( bp_action_variables() ) { bp_do_404(); return; } // Define local defaults $bp = buddypress(); // The instance $email_error = false; // invalid|blocked|taken|empty|nochange $pass_error = false; // invalid|mismatch|empty|nochange $pass_changed = false; // true if the user changes their password $email_changed = false; // true if the user changes their email $feedback_type = 'error'; // success|error $feedback = array(); // array of strings for feedback. // Nonce check. check_admin_referer('bp_settings_general'); // Validate the user again for the current password when making a big change. if ( ( is_super_admin() ) || ( !empty( $_POST['pwd'] ) && wp_check_password( $_POST['pwd'], $bp->displayed_user->userdata->user_pass, bp_displayed_user_id() ) ) ) { $update_user = get_userdata( bp_displayed_user_id() ); /* Email Change Attempt ******************************************/ if ( !empty( $_POST['email'] ) ) { // What is missing from the profile page vs signup - // let's double check the goodies. $user_email = sanitize_email( esc_html( trim( $_POST['email'] ) ) ); $old_user_email = $bp->displayed_user->userdata->user_email; // User is changing email address. if ( $old_user_email != $user_email ) { // Run some tests on the email address. $email_checks = bp_core_validate_email_address( $user_email ); if ( true !== $email_checks ) { if ( isset( $email_checks['invalid'] ) ) { $email_error = 'invalid'; } if ( isset( $email_checks['domain_banned'] ) || isset( $email_checks['domain_not_allowed'] ) ) { $email_error = 'blocked'; } if ( isset( $email_checks['in_use'] ) ) { $email_error = 'taken'; } } // Store a hash to enable email validation. if ( false === $email_error ) { $hash = wp_hash( $_POST['email'] ); $pending_email = array( 'hash' => $hash, 'newemail' => $user_email, ); bp_update_user_meta( bp_displayed_user_id(), 'pending_email_change', $pending_email ); $verify_link = bp_displayed_user_domain() . bp_get_settings_slug() . '/?verify_email_change=' . $hash; // Send the verification email. $args = array( 'tokens' => array( 'displayname' => bp_core_get_user_displayname( bp_displayed_user_id() ), 'old-user.email' => $old_user_email, 'user.email' => $user_email, 'verify.url' => esc_url( $verify_link ), ), ); bp_send_email( 'settings-verify-email-change', bp_displayed_user_id(), $args ); // We mark that the change has taken place so as to ensure a // success message, even though verification is still required. $_POST['email'] = $update_user->user_email; $email_changed = true; } // No change. } else { $email_error = false; } // Email address cannot be empty. } else { $email_error = 'empty'; } /* Password Change Attempt ***************************************/ if ( !empty( $_POST['pass1'] ) && !empty( $_POST['pass2'] ) ) { if ( ( $_POST['pass1'] == $_POST['pass2'] ) && !strpos( " " . $_POST['pass1'], "\\" ) ) { // Password change attempt is successful. if ( ( ! empty( $_POST['pwd'] ) && $_POST['pwd'] != $_POST['pass1'] ) || is_super_admin() ) { $update_user->user_pass = $_POST['pass1']; $pass_changed = true; // The new password is the same as the current password. } else { $pass_error = 'same'; } // Password change attempt was unsuccessful. } else { $pass_error = 'mismatch'; } // Both password fields were empty. } elseif ( empty( $_POST['pass1'] ) && empty( $_POST['pass2'] ) ) { $pass_error = false; // One of the password boxes was left empty. } elseif ( ( empty( $_POST['pass1'] ) && !empty( $_POST['pass2'] ) ) || ( !empty( $_POST['pass1'] ) && empty( $_POST['pass2'] ) ) ) { $pass_error = 'empty'; } // The structure of the $update_user object changed in WP 3.3, but // wp_update_user() still expects the old format. if ( isset( $update_user->data ) && is_object( $update_user->data ) ) { $update_user = $update_user->data; $update_user = get_object_vars( $update_user ); // Unset the password field to prevent it from emptying out the // user's user_pass field in the database. // @see wp_update_user(). if ( false === $pass_changed ) { unset( $update_user['user_pass'] ); } } // Clear cached data, so that the changed settings take effect // on the current page load. if ( ( false === $email_error ) && ( false === $pass_error ) && ( wp_update_user( $update_user ) ) ) { wp_cache_delete( 'bp_core_userdata_' . bp_displayed_user_id(), 'bp' ); $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() ); } // Password Error. } else { $pass_error = 'invalid'; } // Email feedback. switch ( $email_error ) { case 'invalid' : $feedback['email_invalid'] = __( 'That email address is invalid. Check the formatting and try again.', 'buddypress' ); break; case 'blocked' : $feedback['email_blocked'] = __( 'That email address is currently unavailable for use.', 'buddypress' ); break; case 'taken' : $feedback['email_taken'] = __( 'That email address is already taken.', 'buddypress' ); break; case 'empty' : $feedback['email_empty'] = __( 'Email address cannot be empty.', 'buddypress' ); break; case false : // No change. break; } // Password feedback. switch ( $pass_error ) { case 'invalid' : $feedback['pass_error'] = __( 'Your current password is invalid.', 'buddypress' ); break; case 'mismatch' : $feedback['pass_mismatch'] = __( 'The new password fields did not match.', 'buddypress' ); break; case 'empty' : $feedback['pass_empty'] = __( 'One of the password fields was empty.', 'buddypress' ); break; case 'same' : $feedback['pass_same'] = __( 'The new password must be different from the current password.', 'buddypress' ); break; case false : // No change. break; } // No errors so show a simple success message. if ( ( ( false === $email_error ) || ( false == $pass_error ) ) && ( ( true === $pass_changed ) || ( true === $email_changed ) ) ) { $feedback[] = __( 'Your settings have been saved.', 'buddypress' ); $feedback_type = 'success'; // Some kind of errors occurred. } elseif ( ( ( false === $email_error ) || ( false === $pass_error ) ) && ( ( false === $pass_changed ) || ( false === $email_changed ) ) ) { if ( bp_is_my_profile() ) { $feedback['nochange'] = __( 'No changes were made to your account.', 'buddypress' ); } else { $feedback['nochange'] = __( 'No changes were made to this account.', 'buddypress' ); } } // Set the feedback. bp_core_add_message( implode( "\n", $feedback ), $feedback_type ); /** * Fires after the general settings have been saved, and before redirect. * * @since 1.5.0 */ do_action( 'buddydev_profile_general_save' ); // Redirect to prevent issues with browser back button. bp_core_redirect( trailingslashit( bp_displayed_user_domain() . $bp->profile->slug . '/general' ) ); } add_action( 'bp_actions', 'buddydev_profile_general_save' );
And also you need to modify “buddypress/bp-templates/bp-legacy/buddypress/members/single/profile.php” and place the following code after line no. 56
case 'general' : // Display XProfile if (bp_is_my_profile() ) { bp_get_template_part( 'members/single/settings/general' ); } break;
Thank You
Ravi