Show Solution - Conditional Visibility
Submitted by clonecorp on Wed, 08/04/2021 - 20:44
Forums:
Hello,
I have looked for ways I can mod H5P on my WordPress installation. My goal is to display or hide the 'Show Solution' button depending on the user's role for all the content type. I haven't found anything so far. Any help?
Thank you,
Jordan.
otacke
Wed, 08/04/2021 - 21:15
Permalink
Hi Jordan!You may have been
Hi Jordan!
You may have been looking in the wrong places: the hooks for altering the stylesheets and for adding custom scripts are described at https://h5p.org/wordpress-customization and in the code of https://github.com/h5p/h5pmods-wordpress-plugin that is linked to on that page.
Best,
Oliver
clonecorp
Wed, 08/04/2021 - 21:53
Permalink
Let me know if I'm correct
So, if I understand you properly. I have to create a h5pmods_alter_semantics function modifying the semantics when the current logged in user has a certain role. Is that correct ?
Thanks,
Jordan.
otacke
Wed, 08/04/2021 - 23:13
Permalink
It will ultimately depend on
It will ultimately depend on what exactly you want to achieve, but you'll probably not need the alter_semantics hook. You'll rather want to fire up the alter_styles hook (e.g. to hide the buttons via some extra CSS) or the alter_scripts hook (e.g. if CSS alone is not enough, because the content type does something programmatically) based on the current user role.
Best,
Oliver
clonecorp
Sat, 08/07/2021 - 05:13
Permalink
Thanks. I managed to do it. I
Thanks. I managed to do it. I'll ultimately customize the semantics as well because it's a nice feature. Thank you for your guidance.
Have a good weekend,
Jordan.