BuddyDev

Search

[Resolved] Remove the subject line requirement in messages?

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #28377

    My theme also supports setting in custom hooks like one of the BP action hooks

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #28378

    Hi, I can see I have got a syntax error here?

    Uncaught SyntaxError: Invalid or unexpected token

    jQuery(document).ready(function() {

    jQuery(‘#send_message_form’).submit( function() {
    jQuery(‘#subject’).val(“Some message subject”);
    });
    });

  • Keymaster
    (BuddyDev Team)
    Posts: 24232
    Brajesh Singh on #28379

    Please try adding this to your bp-custom.php

    
    
    add_action( 'wp_footer', function () {
    	?>
    	<script type="text/javascript">
            jQuery(document).ready(function ($) {
    
                if ($('#send_message_form #subject').length) {
                    $('#send_message_form #subject').val('Some message subject');
                }
            });
    	</script>
    	<?php
    } );
    
    

    Let me know if i works or not?

    It assumes that the theme loads jQuery.

    Regards
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #28380

    Hi Brajesh, thanks for the code, which works once, on the first new message but not on following new message?

  • Keymaster
    (BuddyDev Team)
    Posts: 24232
    Brajesh Singh on #28381

    Hi Carsten,

    You are welcome.

    Are you not using the bp-legacy template? If you are using it, the compose screen will need page reload each time you want to compose a message. And if a page is loaded, the code should work fine.

    Regards
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #28382

    Hi Brajesh, yes, I’m using bp-legacy template. This happens after visiting and writing a new profile so the page must be reloaded.

    I found this edit in my messages-loop.php in my child theme, kan this cause this. Honestly, I can’t remember why this code was added, and what it does?

    
    
    <?php
    $mssender = strip_tags(bp_get_message_thread_from(), '<br>');
    ?>
    <span class="from"><?php _e( 'From:', 'buddypress' ); ?></span> <?php bp_message_thread_from(); ?>
    
    <a href="<?php bp_message_thread_view_link( bp_get_message_thread_id(), bp_displayed_user_id() ); ?>" class="bp-tooltip" data-bp-tooltip="<?php esc_attr_e( "View Message", 'buddypress' ); ?>" aria-label="<?php esc_attr_e( "View Message", 'buddypress' ); ?>"><?php echo $mssender; ?><span class="activity"><?php bp_message_thread_last_post_date(); ?></span></a>

    Original code:

    <span class="from"><?php _e( 'From:', 'buddypress' ); ?></span> <?php bp_message_thread_from(); ?>

    Regards
    Carsten

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #28383

    Adding the original code, didn’t help.

    I figured it out, what this code snippet does is to link both the avatar and the user name, in the message thread, to the conversation instead of the profile

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #28384

    Hi Brajesh, the code is working now, again, thank you very much for the extraordinary help and support you are offering.

    Best
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24232
    Brajesh Singh on #28388

    Hi Carsten,
    Thank you for confirming. I am glad it worked.

    Regards
    Brajesh

The topic ‘[Resolved] Remove the subject line requirement in messages?’ is closed to new replies.

This topic is: not resolved