- This topic has 15 replies, 3 voices, and was last updated 1 month, 1 week ago by
Leo.
-
AuthorPosts
-
June 23, 2022 at 12:32 pm #2262657
Tomáš
Hello,
I would like to ask you for a help with adding a custom elements (blocks) inside Tutor LMS pages/templates.
For example: I would like to add a simple heading after the course enrolment button.
How would I go about doing that?
I played a bit with custom elements (Appearance -> Elements -> Add new -> Block), I set the location to “Course” and then on a sidebar I choosed “Element type -> Hook” , and for Hook name I choosed “Custom hook”.
Then I tried to look up the tutor lms documentation and I found this: https://docs.themeum.com/tutor-lms/developers/hooks/
But honestly I don’t know how to use this.
Any help would be much appreciated. Thank you.
June 23, 2022 at 12:36 pm #2262663Leo
StaffCustomer SupportHi there,
then on a sidebar I choosed “Element type -> Hook” , and for Hook name I choosed “Custom hook”.
That’s the correct method. From there, you would need to enter the name of the custom hook and it depends on where you are trying to insert the content.
This is something you will need to check with TutorLMS’ support team.
I don’t believe the page you’ve linked is what you need but their support team should be able to clarify.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/June 24, 2022 at 5:13 am #2263143Tomáš
So I wrote to Tutor LMS support and they responded with this:
“You can use this hook to add: https://docs.themeum.com/tutor-lms/developers/hooks/templates/#course-enroll-box-php”
However, I am not quite sure how to target this and what should I enter in “Custom hook” field.
Could you please help me with this?
June 24, 2022 at 5:30 am #2263160David
StaffCustomer SupportHi there,
1. Create your block element.
2. Set the Element Type to Hook.
2.1 in the hook list select Custom Hook.
2.2 in the Field paste in:tutor_course/single/enroll_box/after_thumbnail
3. Set your Display Rules > Location to the Tutor Course Single ? – i am not sure what it will be called but look through the list of options.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/June 24, 2022 at 5:33 am #2263161Tomáš
Thank you David. I did exactly the same as you state above but it doesn’t work.
As for a display rules, there is a location “Course”. So I set that.
But when I did exactly this, it doesn’t work. Would it help you if I give you a temporary access to my site?
June 24, 2022 at 5:51 am #2263180David
StaffCustomer SupportCan you link me to the page where it should display ?
If i need a login or anything, then you can share those details in the Private Information field.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/June 24, 2022 at 5:52 am #2263181Tomáš
Sure David, here is the course page.
June 24, 2022 at 6:41 am #2263211David
StaffCustomer SupportIf you temporarily change the Hook to:
before_header
which is in the list of hooks. Does your block element content display? It should be above the site headerIf it does, then we know the Display Rules are correct and the custom hook is bad
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/June 24, 2022 at 9:45 am #2263484Tomáš
So I changed the hook to
before_header
and it does display on the frontend as it should.So, the custom hook we try to locate is bad.
I noticed that after I add this hook
tutor_course/single/enroll_box/after_thumbnail
in GP Theme (custom hook), after I save it and reload the page, it loses those/
(slashes), so therefore, it looks like thistutor_coursesingleenroll_boxafter_thumbnail
June 25, 2022 at 5:45 am #2263951David
StaffCustomer SupportTo be honest i have never seen hook method with
/
being used in this way before.Can you check with Tutor on how they expect us to use it ?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/June 27, 2022 at 6:46 am #2265722Tomáš
Hello David,
so I wrote to Tutor LMS Support and I got this answer:
As he was referring to this hook tutor_course/single/enroll_box/after_thumbnail , you can use this, using this you can add your custom section.
Best Regards,
Which, I would say, doesn’t help us in any way..question is what now?
June 27, 2022 at 7:13 am #2265754David
StaffCustomer SupportTry adding this PHP Snippet to your site:
add_action('tutor_course/single/enroll_box/after_thumbnail', function(){ echo 'if i see this text then the hook is working'; });
Do you see the text appear on the page ?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/June 27, 2022 at 7:19 am #2265761Tomáš
I added the above PHP snippet and the text “if i see this text then the hook is working” is displaying on every page before the <header> tag
June 27, 2022 at 7:23 am #2265764David
StaffCustomer SupportOk – so…. i have no clue how that Hook is meant to work then lol
Could you share this topic with them? So they can see what we’re trying to do and maybe educate us on how to do it properly?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/June 29, 2022 at 10:46 am #2268436Tomáš
So I received this message from Tutor LMS:
I think This customization will not gonna work with this hook. Send me a screenshot of exactly where after the course enrollment button you want to add the heading. I will try to share the direct code if possible. The hook is not going to work.
And then, they provided me with the following function:
function your_func(){ echo 'here add custimiztion'; } add_action('tutor_course/single/enroll_box/after_thumbnail', 'your_func');
So if I am right, does this mean that I won’t be able to use GeneratePress hook system to display elements? Or is there any easier way than to write custom functions?
-
AuthorPosts
- You must be logged in to reply to this topic.