Created
March 31, 2019 07:35
-
-
Save cryptexvinci/0d28b19dfd09449ac36b8939768d376b to your computer and use it in GitHub Desktop.
Display Message Button only when a user is logged in.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| remove_action( 'um_profile_navbar', array( UM()->Messaging_API()->profile(), 'add_profile_bar' ), 5 ); | |
| add_action( 'um_profile_navbar', 'custom_add_profile_bar', 6 ); | |
| function custom_add_profile_bar( $args ) { | |
| $user_id = um_profile_id(); | |
| if ( is_user_logged_in() ) { | |
| if ( get_current_user_id() == $user_id ) { | |
| return; | |
| } | |
| if ( ! UM()->Messaging_API()->api()->can_message( $user_id ) ) { | |
| return; | |
| } | |
| } | |
| wp_enqueue_script( 'um-messaging' ); | |
| wp_enqueue_style( 'um-messaging' ); ?> | |
| <?php if ( is_user_logged_in() ) : ?> | |
| <div class="um-messaging-btn"> | |
| <?php echo do_shortcode( '[ultimatemember_message_button user_id="' . $user_id . '"]' ) ?> | |
| </div> | |
| <?php endif; ?> | |
| <?php | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment