Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * BuddyPress for Sensei: Contact lessaon teacher(Messaging recipient fix)
- */
- function bboss_custom_sensei_send_message_link() {
- global $BUDDYPRESS_SENSEI;
- remove_action( 'sensei_single_lesson_content_inside_before', array( $BUDDYPRESS_SENSEI->bp_sensei_loader, 'bp_sensei_send_message_link' ), 110 );
- add_action( 'sensei_single_lesson_content_inside_before', 'bboss_sensei_send_message_link', 110 );
- }
- add_action( 'init', 'bboss_custom_sensei_send_message_link', 99 );
- /**
- * Sensei send message link override
- */
- function bboss_sensei_send_message_link() {
- global $woothemes_sensei, $post;
- $sensei_message_class_object = $woothemes_sensei->post_types->messages;
- if ( ! ( is_singular( 'course' ) || is_singular( 'lesson' ) ) ) return;
- $html = '';
- if( ! isset( $woothemes_sensei->settings->settings['messages_disable'] ) || ! $woothemes_sensei->settings->settings['messages_disable'] ) {
- if( ! is_user_logged_in() ) return;
- if( isset( $_GET['contact'] ) ) {
- $html .= $sensei_message_class_object->teacher_contact_form( $post );
- } else {
- $href = esc_url(add_query_arg( array( 'contact' => $post->post_type ) ));
- if( bp_is_active( 'messages' ) ){
- $user_domain = bp_loggedin_user_domain();
- $messages_link = trailingslashit( $user_domain . BP_MESSAGES_SLUG );
- $compose_link = trailingslashit( $messages_link . 'compose' ) . '?r=' . bp_core_get_username( $post->post_author );
- $html .= '<p class="bp-sensei-msg-link"><a class="button send-message-button" href="' . $compose_link . '">' . sprintf( __( 'Contact %1$s Teacher', 'sensei-buddypress' ), ucfirst( $post->post_type ) ) . '</a></p>';
- }else{
- $html .= '<p class="bp-sensei-msg-link"><a class="button send-message-button" href="' . $href . '#private_message">' . sprintf( __( 'Contact %1$s Teacher', 'sensei-buddypress' ), ucfirst( $post->post_type ) ) . '</a></p>';
- }
- }
- if( isset( $sensei_message_class_object->message_notice ) && isset( $sensei_message_class_object->message_notice['type'] ) && isset( $sensei_message_class_object->message_notice['notice'] ) ) {
- $html .= '<div class="sensei-message ' . $sensei_message_class_object->message_notice['type'] . '">' . $sensei_message_class_object->message_notice['notice'] . '</div>';
- }
- }
- echo $html;
- }
Add Comment
Please, Sign In to add comment