Simple Membership Plugin › Forums › Simple Membership Plugin › Add a template loader
- This topic has 4 replies, 3 voices, and was last updated 10 years, 8 months ago by
mikolai.
-
AuthorPosts
-
January 30, 2016 at 1:55 pm #5071
mikolai
ParticipantHi,
I would like to modify the template parts named ‘login.php’, ‘loggedin.php’ etc. and place these modified files in a subfolder of my theme (so that they actually remain when upgrading to a new version of SWPM). The Plugin should then check if a template with the required name exists within a certain folder (e.g. ‘simple-membership-plugin) and if yes, should load this instead of the standard template located in the plugin folder. Basically, it would be like for example ‘bbpress’ does it and a real improvement of your plugin!
My suggestion would be a function similar to this:
function load_template( $name ) { $files = array( get_stylesheet_directory() . '/simple-membership/'.$name, //First check inside child theme get_template_directory() . '/simple-membership/'.$name, //then inside theme folder SIMPLE_WP_MEMBERSHIP_PATH . 'views/'.$name //otherwise load standard template ); foreach ($files as $file) { if ( file_exists( $file ) ) { include ( $file ); break; } } }Inside class.simple-wp-membership.php, you should then change every
include('{template}.php')toload_template('{template}.php'). Didn’t test it, but I think it should work 🙂Would be great if you could add this feature to the plugin!
Regards,
MikolaiJanuary 30, 2016 at 9:30 pm #5073mbrsolution
ModeratorHi Mikilai, thank you for your code and suggestion. The plugin developers will further test your code and report back.
Kind regards
February 2, 2016 at 12:07 pm #5109admin
KeymasterThis is a good idea. We would like to add something similar to this in the plugin.
February 26, 2016 at 1:15 pm #5496admin
KeymasterThis functionality has been added to the plugin.
https://simple-membership-plugin.com/customizing-the-look-of-the-membership-login-widget/
March 2, 2016 at 6:52 pm #5599mikolai
ParticipantHi,
thank you so much for the implementation, your support is really great!
I’ve checked the new version out and it works perfectly for login and forgot-password, but it’s not working for the register form. Indead, I searched a bit in the code and I saw it being loaded inside class.swpm-front-registration.php in line 62. It would be great if you could extend the functionality to this class too!
Regards,
mikolai -
AuthorPosts
- You must be logged in to reply to this topic.