Site logo

Archived topic

Add Element (Hook) to custom template

6 replies · Started by Timo de Vries on March 7, 2021

Viewing posts 1–7 of 7

Hi,

I am using the Restrict Content Pro plugin. They provide (PHP-)templates to overwrite in my child theme.
How can I add an GP element to these templates? Something like registering a new custom hook position I can add content to?
Thanks!

Hi there,

How can I add an GP element to these templates? Something like registering a new custom hook position I can add content to?

Yes you'll pretty much have to register a custom hook if you have a specific place within the template you want to hook something.

It's quite simple. See do_action(): https://developer.wordpress.org/reference/functions/do_action/

Hi,

I just noticed that there is already a hook in the template at the specific place I was looking for:

<?php
do_action( 'rcp_register_total_details_footer_bottom' );
?>

I have created an Element (Block), set block type to "Hook", set location to "entire site" and custom hook name to "rcp_register_total_details_footer_bottom". Unfortunately it doesn't show up on the page. Any ideas what I am doing wrong?

Display rule location can be a possible cause. Perhaps it wasn't set properly.

It's also best to test if the hook is working.

To test, try creating a Hook element containing this -
<h1> This is rcp_register_total_details_footer_bottom hook </h1> - hooked to rcp_register_total_details_footer_bottom and set the display rule location appropriate to where it's supposed to appear.

"This is rcp_register_total_details_footer_bottom hook" text should appear assuming you've set the display rule location and the hook correctly.

If it doesn't, it's possible that the hook isn't in use.

I tried to set the display rule location to the specific page before, but had no luck. What can I do to get that hook “in use”?

Found another hook in the template that seems to work :-)

For those looking for a solution: rcp_before_registration_submit_field

I'm not sure which pages or posts uses it to know where it works.

Found another hook in the template that seems to work 🙂

For those looking for a solution: rcp_before_registration_submit_field

Nice one. Have you fully sorted it out? Let us know.

This archived topic is closed to new replies.