Get thread id for existing conversation for users or not create new conversation,
$threadId = buddydev_get_threads_between_users($sender_id, $recip_id );
if(empty($threadId)){
if ( $thread_id = messages_new_message( array('sender_id' => $sender_id, 'subject' => $subject, 'content' => $message, 'recipients' => $recip_id ) ) ) {
bp_core_add_message( __('Message was sent.', 'buddypress' ) );
} else {
bp_core_add_message( __( 'There was an error sending Message.', 'buddypress' ), 'error' );
}
}
else{
if ( messages_new_message( array('sender_id' => $sender_id, 'thread_id' => $threadId[0], 'subject' => $subject, 'content' => $message, 'recipients' => $recip_id ) ) ) {
bp_core_add_message( __('Message was sent.', 'buddypress' ) );
bp_core_redirect( $bp->displayed_user->domain ); // adjust as needed
} else {
bp_core_add_message( __( 'There was an error sending Message.', 'buddypress' ), 'error' );
}
}
Related Posts:
- How to Modify/Change a Buddypress/WordPress Account Activation Process
- Integrating Buddypress, Wootumblog and WPMU Sitewide tags
- BuddyPress: Allow only one email domain to register
- Add BuddyPress Profile Menu Item [closed]
- wp_editor on front end – JavaScripts not included
- How to force buddypress users to complete profile after registration? [closed]
- how to get current user name by user_id in buddypress?
- How to override Member’s Avatars in BuddyPress [closed]
- Buddypress send email notification only if user is not logged in [closed]
- Delete all user attachments
- Login redirect to certain bp profile page
- Buddypress and WordPress on different subdomains with the same database?
- How to reply to Buddypress notifications? [closed]
- BuddyPress: How to get info of users filtered by some x-profile data? [closed]
- How to check if the current page is a “personal activity”-page in buddypress? [closed]
- Buddypress get member meta info for specific user ID [closed]
- How to Change BuddyPress Mystery Man Graphic without Overwriting Core Image File [closed]
- How to get larger version of author avatar
- Exclude User from Activity Stream in BuddyPress?
- How to run scripts when a new blog is created in Buddypress?
- Showing the user’s username in registration email or activation page with BuddyPress [closed]
- Display four buddypress activies [closed]
- How to remove unused avatar uploads in buddypress [closed]
- Buddypress Fake (non-bot) Users [closed]
- BuddyPress | How to merge the “setting” & “profile” pages into one page? [closed]
- cubepoints/buddypress show new rank on activity? [closed]
- Upload files into buddypress profiles [closed]
- Is it possible to have a network of BuddyPress sites, a-la WordPress MU, with single-sign-on? [closed]
- Is there a plugin or something that allows you to use BuddyPress without having to create a BuddyPress-ready theme?
- Buddypress – adding custom post to members
- BuddyPress – Get a List of Defined xProfile fields [closed]
- Buddypress Registartion template [closed]
- Can you use the buddypress profile system without installing the whole of buddypress? [closed]
- How to auto-accept a friend-request in buddypress based on user meta
- Best practices for securing a Buddypress installation?
- After Upgrade to Buddypress 1.2.6 from 1.2.5.2 , admin bar area displayed incorrectly for guest-visitors
- switch_to_blog( ) content disappears after load
- Buddypress bp_has_members function custom search with meta query [closed]
- Buddypress, BBPress – deqeue bp, bbp css and get group member count
- buddypress activity social share
- Wrong path when adding custom tab in BuddyPress [closed]
- How to carry over existing wp users to a new buddypress installation [closed]
- Buddypress export Profile Fields [closed]
- Capture Webcam Video within Buddypress (and BuddyPress Media) [closed]
- New Post Notifications for Users – BUDDYPRESS
- BuddyPress: Conditionally filter directory based on Xprofile Field [closed]
- Will multiple BuddyPress groups slow down a site? [closed]
- Showing content to specific BuddyPress Member Types
- Save buddypress xprofile data to author meta
- Format Buddypress Date Picker Output [closed]
- WordPress SEO plugin (by Yoast) and BuddyPress [closed]
- How to get the group_id from the “groups_join_group” action in buddypress [closed]
- Truncate latest activity in buddypress
- Conditional tags to differentiate between profiles and activity with buddypress [closed]
- How can I display a buddypress group name in the header.php so that it shows when viewing each single group? [closed]
- How to add an error or notification to an activity?
- Fill the content of newly added Profile Tab (BuddyPress)
- Buddypress Welcome Email [closed]
- Change xprofile visibility options in Buddypress [closed]
- How to get all users that uploaded avatars or have gravatars? [closed]
- Buddypress – adding profile fields to Group > Members directory [closed]
- how to make all buddypress users status “recently active”? [closed]
- WordPress Super Admin menu not enabled
- SQL Query members by profile fields Buddypress [closed]
- WordPress/Buddypress theme has suddenly stopped working [closed]
- BuddyPress user bio in profile [closed]
- How to make the BuddyBar fix and scroll with the page
- bbpress plug-ins and buddypress [closed]
- BuddyPress redirecting to home page on login [closed]
- Buddypress integration with wordpress
- How to split out BuddyPress notifications drop down items to their own top level? [closed]
- BuddyPress – User Login instead of Full Name [closed]
- Displaying the errors from my BuddyPress script
- BP Profile Search with limited range
- validation email signup form buddypress
- bp_core_new_subnav_item shows new group tab but returns 404 when the tab runs. Works on another page
- Limit the total space in every user
- how can i add the repeater field in buddy press user edit profile
- Return instead of echo
- Upload buddy press profile picture from custom page template
- How can I display list of notifications of buddypress in a single page or post
- Buddypress: Filter Members Based on If They Have Posts
- Buddypress user registration validation not working with custom select query
- Causing my WordPress functions to execute twice
- New accounts daily at WP Multi-User site under development, Analytics reports no traffic. What gives?
- Strange issues on sign up form
- How can I place ad code after every 5 activities in BuddyPress activity loop?
- Where am I gaining 6px height retrieving buddypress avatar [closed]
- How to get custom field from BuddyPress Extended Profile
- is it possible to add_action via template.php rather than function.php for this specific buddypress hook?
- Buddypress – Custom Name For Logged In User’s Messages In Message Thread
- Missing “Registration” page with BuddyPress [closed]
- Some ways to debug code
- Adding custom HTML to each profile group tab [closed]
- Is it possible to allow BP Group Admins to Set which Menu Tab they would like to have as their Default landing page? [closed]
- Saving Custom Fields Defined in BuddyPress’ register.php
- buddypress bp_core_add_message() doesn’t fire why? [closed]
- BuddyPress – Message’s Send To auto-fill functionality not working
- Force buddypress groups to be private [closed]
- BuddyPress Activity Stream – Remove/Replace […] from blog post excerpts