gocodebox / lifterlms

LifterLMS, a WordPress LMS Solution: Easily create, sell, and protect engaging online courses.
https://lifterlms.com
GNU General Public License v3.0
178 stars 135 forks source link

Cannot disable Setup Wizard from within Theme code #891

Closed alexmustin closed 3 months ago

alexmustin commented 5 years ago

Currently, the only way to disable the Setup Wizard is by using a plugin.

We need a solution that can allow us to disable the Setup Wizard from within the Theme code.

Reproduction Steps

I tried to add a filter during plugin activation, but this did not work: function disable_liferlms_setup_wizard() { add_filter( 'llms_enable_setup_wizard', '__return_false' ); } add_action( 'activate_lifterlms/lifterlms.php', 'disable_liferlms_setup_wizard' );

I've tried changing the Action for when the code should load, and used the following: activate_lifterlms/lifterlms.php plugins_loaded after_setup_theme init wp_loaded ... but none of these worked.

I tried changing the following values which LifterLMS is checking against: add_filter( 'llms_enable_setup_wizard', '__return_false' ); add_filter( 'llms_prevent_automatic_wizard_redirect', '__return_true' );

I believe the order of the WordPress Actions loading sequence makes it so the Theme code loads too late and the plugin has already checked values and activated the plugin.

Expected Behavior

Actual Behavior

Error Messages / Logs

System Information

System Report ``` Wordpress ------------------------------------------- Home Url: http://localhost/coursemaker-fresh Site Url: http://localhost/coursemaker-fresh Login Url: http://localhost/coursemaker-fresh/wp-login.php Version: 5.2.2 Debug Mode: No Debug Log: No Debug Display: Yes Locale: en_US Multisite: No Page For Posts: Not Set Page On Front: Not Set Permalink Structure: /%year%/%monthnum%/%day%/%postname%/ Show On Front: posts Wp Cron: Yes Settings ------------------------------------------- Version: 3.33.1 Db Version: 3.33.1 Course Catalog: Not Set Membership Catalog: Not Set Student Dashboard: Not Set Checkout Page: Not Set Course Catalog Per Page: 9 Course Catalog Sorting: menu_order Membership Catalog Per Page: 9 Membership Catalog Sorting: menu_order Site Membership: Not Set Courses Endpoint: my-courses Edit Endpoint: edit-account Lost Password Endpoint: lost-password Vouchers Endpoint: redeem-voucher Autogenerate Username: yes Password Strength Meter: yes Minimum Password Strength: strong Terms Required: no Terms Page: Not Set Checkout Names: required Checkout Address: required Checkout Phone: optional Checkout Email Confirmation: yes Open Registration: no Registration Names: required Registration Address: optional Registration Phone: hidden Registration Voucher: optional Registration Email Confirmation: no Account Names: required Account Address: required Account Phone: optional Account Email Confirmation: yes Confirmation Endpoint: confirm-payment Force Ssl Checkout: no Country: US Currency: USD Currency Position: left Thousand Separator: , Decimal Separator: . Decimals: 2 Trim Zero Decimals: no Recurring Payments: yes Email From Address: alex@alexmustin.com Email From Name: CourseMaker TEST Email Footer Text: Email Header Image: Cert Bg Width: 800 Cert Bg Height: 616 Cert Legacy Compat: no Gateways ------------------------------------------- Manual: Disabled Manual Logging: Manual Order: 1 Server ------------------------------------------- Mysql Version: 5.6.38 Php Curl: Yes Php Default Timezone: UTC Php Fsockopen: Yes Php Max Input Vars: 1000 Php Max Upload Size: 8 MB Php Memory Limit: 256M Php Post Max Size: 8M Php Soap: Yes Php Suhosin: No Php Time Limt: 30 Php Version: 7.2.1 Software: Apache Wp Memory Limit: 40M Browser ------------------------------------------- HTTP USER AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36 Theme ------------------------------------------- Name: Twenty Nineteen Version: 1.4 Themeuri: https://wordpress.org/themes/twentynineteen/ Authoruri: https://wordpress.org/ Template: Child Theme: No Llms Support: No Plugins ------------------------------------------- LifterLMS: 3.33.1 Integrations ------------------------------------------- BbPress: No BuddyPress: No Template Overrides ------------------------------------------- ```

Browser, Device, and Operating System Information

thomasplevy commented 5 years ago

@alexmustin

You could try using remove_submenu_page() in the interim: https://codex.wordpress.org/Function_Reference/remove_submenu_page

Additionally, as noted on slack you were wanted to actually stop the first-time install redirect to the setup wizard not actually disable the entire wizard. This filter won't stop the redirect (which is possibly another bug that there's a separate filter for the redirect). However, as I noted in slack this filter should be working (and I tested) to disable the redirect:

add_filter( 'llms_prevent_automatic_wizard_redirect', '__return_true' );

I'll leave this open as a future enhancement but I think the filter here is what we need to discuss for your specific needs.

thomasplevy commented 5 years ago

There's also a semantic argument here about what themes and plugins are responsible for. The traditionally "accepted" definition (and I realize this is a bit reductive) is that themes handle display and plugins handle functionality. The setup wizard is a function of the plugin and really isn't something that I feel themes should need to disable.

As I understand your issue your theme is a Genesis child which has it's own custom setup wizard and, as such, you need to prevent a redirect to our setup wizard during the running of your setup wizard.

Do you actually require the Setup Wizard to be completely unavailable / disabled from within the theme? Or is the issue actually that you need to prevent that first time installation redirect?

alexmustin commented 5 years ago

@thomasplevy You are absolutely correct -- we're looking to stop the first-time install redirect to the setup wizard.

We are developing a Genesis child theme which runs an automated process to install and activate plugins, so we only need the setup disabled during this time. We do want to keep the ability for users to run the Setup Wizard later after the theme is installed.

thomasplevy commented 5 years ago

Got it. I am going to leave this issue open to discuss with some other devs and see if anyone else disagrees that themes should be able to completely disable the setup wizard.

However, the real issue to get you moved along is why the filter llms_prevent_automatic_wizard_redirect doesn't work for you like it does for me.

Have you made any progress on determining why that may not be working for you? I setup a test case on twentynineteen that worked just fine so it's hard for me to say that that filter issue is a bug in LifterLMS. I'm leaning towards it being an issue with Genesis but as of this moment I don't have enough information to determine that for sure.

Let me know your progress there

thomasplevy commented 5 years ago

Here's the steps I took to see whether or not the filter works:

  1. Setup a fresh WP install (one that's NEVER had LifterLMS installed on it).
  2. Add add_filter( 'llms_prevent_automatic_wizard_redirect', '__return_true' ); to the very last line of the functions.php file
  3. Install & Activate LifterLMS

Without the filter, I'd expect to be redirected to the setup wizard. During my test I was not (which is the expected behavior when using the filter.

Are these the steps you're taking (which aren't working)?

alexmustin commented 5 years ago

@thomasplevy - That is correct. Those are the exact steps I'm taking.

alexmustin commented 5 years ago

Ok I apologize but I just realized I never activated my theme first; since it was a fresh install, the default TwentyNineteen theme was still activated so of course my code was never executed.

This filter does work. Sorry for the n00b oversight.

Should I close this issue?

thomasplevy commented 5 years ago

@alexmustin

Cool. I'd like to leave it open and I'll review the initial item about the ability to completely disable with the team during our next bugscrub.

I'll close it after the discussion or reprioritized accordingly.

Thanks!