Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using BuddyPress Message system in other parts of your WC Vendors Site
<?php
/* Buddypress Private Messaging Mod */
/*
Usage :
Put this in your templates to create a message link you can then style
templates this could go in :
* description.php (put the message link in the end of the description)
* content-singple-product.php (place this message above the item details, if you combine this with a small vendor header)
* order-details.php (allows them to message about an order)
* archive-product.php (Put a vendor header in the per vendor product pages)
if ( function_exists('bp_is_active') ) { ?>
<a href="<?php echo bp_custom_get_send_private_message_link($product->post->post_author,'Subject here','Predefined message Information');?>">> MESSAGE SELLER</a>
<?php } ?>
*/
// Change the Buddypress Search Slug to stop search collision.
define( 'BP_SEARCH_SLUG', 'searching' );
function bp_custom_get_send_private_message_link($to_id, $subject=false, $message=false) {
//if user is not logged, do not prepare the link
if ( !is_user_logged_in() ) return false;
$compose_url=bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?';
if($to_id)
$compose_url.=('r=' . bp_core_get_username( $to_id ));
if($subject)
$compose_url.=('&subject='.$subject);
if($message)
$compose_url.=('&content='.$message);
return wp_nonce_url( $compose_url ) ;
}
/*
Auto populate the message content
*/
add_filter('bp_get_messages_content_value','bp_custom_message_content_value');
function bp_custom_message_content_value($content){
if(!empty ($content)) return $content;
$content=$_REQUEST['content'];
return $content;
}
/*
Auto Populate subject
*/
add_filter('bp_get_messages_subject_value','bp_custom_get_messages_subject_value');
function bp_custom_get_messages_subject_value($subject){
if(!empty($subject))
return $subject;
$subject=$_REQUEST['subject'];
return $subject;
}
?>
@digitalchild
Copy link
Author

digitalchild commented Oct 16, 2014

This should go in a file called bp-custom.php in your wp-content/plugins/ directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment