Archived topic
Add a function to a Block element
3 replies · Started by Carsten on September 18, 2020
Hi there, I'm using a block element to add a Heading on my BP profile page using the hook bp_after_profile_content. before there was issues with Elements and BP hook, but now it seems to work, so that is great.
I want the heading to display on all profiles than own profile, but there are no hook for that. But it is possible to use a function like
if ( bp_is_my_profile() ) {
// my profile.
} else {
// not my profile.
}
My question is if it would be possible to add such a function to a Block element, like a content field, for adding extra code, like this function?
Thanks!
Hi there,
unfortunately not - Block Elements will not accept PHP.
You could of course create a shortcode, which can be added using the shortcode block, to output your custom function.
https://docs.generatepress.com/article/creating-a-shortcode/
Hello. Sorry I hijack the topic: so for integration with ACF I will need to use shortcodes , right?
Hi Marcel,
for now that is correct - we'll be implementing template tags for the Block Element in GPP 1.13 - this may support some custom fields :)