From c34d4713d39939851184c331133b13d04ef03b6a Mon Sep 17 00:00:00 2001 From: Boro Sitnikovski Date: Fri, 21 Oct 2016 04:28:03 +0200 Subject: [PATCH] Use WordPress to register/login instead of built-in functions. Fixes https://github.com/Automattic/sensei/issues/1202. --- includes/class-sensei-course.php | 10 +++ templates/user/login-form.php | 109 ------------------------------- 2 files changed, 10 insertions(+), 109 deletions(-) delete mode 100644 templates/user/login-form.php diff --git a/includes/class-sensei-course.php b/includes/class-sensei-course.php index 361eb18b63b..4041c226399 100755 --- a/includes/class-sensei-course.php +++ b/includes/class-sensei-course.php @@ -116,12 +116,22 @@ public function __construct () { // flush rewrite rules when saving a course add_action('save_post', array( 'Sensei_Course', 'flush_rewrite_rules' ) ); + add_action( 'template_redirect', array( $this, 'course_login' ), 10, 1 ); + + // Allow course archive to be setup as the home page if ( (int) get_option( 'page_on_front' ) > 0 ) { add_action( 'pre_get_posts', array( $this, 'allow_course_archive_on_front_page' ) ); } } // End __construct() +public function course_login() { + if ( is_page( 'my-courses' ) && ! is_user_logged_in() ) { + + wp_redirect( wp_login_url( get_permalink() ) ); + } +} + /** * Fires when a quiz has been graded to check if the Course status needs changing * diff --git a/templates/user/login-form.php b/templates/user/login-form.php deleted file mode 100644 index 6beeee7add2..00000000000 --- a/templates/user/login-form.php +++ /dev/null @@ -1,109 +0,0 @@ - - - - -

- -
- - - - - - - - - - - -

- - - -

- - - - - - - - - -
- -
- - \ No newline at end of file