Site logo

Archived topic

BuddyPress custom js code into GP?

20 replies · Started by Carsten on November 23, 2018

Viewing posts 16–21 of 21

Hi there, I'm taking up this old topic since it's relevant to me again

I was advised to use a hook to add this js

<script type="text/javascript">
  jQuery(document).ready(function() {

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

But how can I add this hook with GP, the only place for hooks I know is in an element

Regards
Carsten

Try adding that in wp_footer hook in hooks element.

Hi, sorry, this is not working, would you please check the script syntax for me?

This is a js for BP, please explain how a script added to the WP_footer can influence BP content?

Should Execute PHP be marked?

Maybe the wrong quotation marks?

<script type="text/javascript">
  jQuery(document).ready(function() {

jQuery('#send_message_form').submit( function() {
jQuery('#subject').val("Some message subject");
});
 });
</script>

Unfortunately I'm not sure what the code is supposed to do - this is something you will need to check with BP's support.

wp_footer is a WordPress hook and usually is the place to add custom js code.

Execute PHP does not need to be checked.

The code is supposed to fill out a default Subject to a message.

This is the message I got from BP support, when I raised the question a while back.

You can put that in your theme’s javascript file. Look for js file in your theme.

Since it is just 2 lines of code, My suggestion will be to put it in one of the js file provided by theme. Look for a file named buddypress.js and you can put the code inside the dom ready section there. If you are using a custom theme, you may ask there(or check their documents) to see if there is any custom js file supported.

Definitely wouldn't suggest adding that to the theme's file as it will be erased during updates.

Can you check with them to see if it can be added using wp_footer hook?

This archived topic is closed to new replies.