do_action is a WP thing. Tons of info on it. Google it.
Given all the things you’re trying to do ( based on your posts to these forums ) you’ll be a lot more effective if you start learning about the environment you’re coding in.
@shanebp I only ever post in the forums once i’ve Googled/read the Codex and still not fully understood a topic. Apologies if i’ve asked lots of questions today, your help has been much appreciated :}
No problem.
Don’t forget that you’re trying to learn two code bases – WP and BP – so you’ll have to look web-wide.
@thirstcard
The do_action() creates a hook. Basically it prints out the contents of the function that is added to that tag (bp_after_message_content) with add_action.
Usage? Let’s say Developer A makes a plugin that will place some text at the bottom of message contents, Instead of the end user having to edit the theme templates to add a call to the function, the developer can use `add_action(‘bp_after_message_content’, ‘plugins_function_that_does_stuff’);` WordPress will remember that function and will print it out where it finds `do_action( ‘bp_after_message_content’ )`
Does that help?
@ChrisClayton
Ah, I see now & I can see where using these would be useful – there is no need to edit the WordPress/BuddyPress core.
The part I couldn’t get my head around was why you wouldn’t just place the whole function in the theme but now I realise by using do_action() you can insert multiple functions at that specific particular point in the code.
Thanks for helping out!
Yep it just represents an insertion point in a file, marker points throughout a theme template file where ‘stuff’ may be added.
The wp_footer() and wp_head() functions located in the footer and header files use just do_action to print all of there ‘stuff’ (meta, css, js etc).
https://core.trac.wordpress.org/browser/tags/3.3.2/wp-includes/general-template.php#L1576