Show Solution - Conditional Visibility

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's picture

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 

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's picture

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 

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.