Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lesson notices filters #5087

Merged
merged 3 commits into from
May 9, 2022

Conversation

renatho
Copy link
Contributor

@renatho renatho commented Apr 29, 2022

Part of #5068

Changes proposed in this Pull Request

  • It adds some filters allowing to customize links used in lesson notices (login, registration and take course).
    • It was implemented as filters only because our Learning Mode block is a generic block for any type of notices.

Testing instructions

  • Add the following filters to your site:
    add_filter(
    	'sensei_lesson_take_course_url',
    	function( $take_course_url, $course_id ) {
    		return 'http://lesson-take-course.com?' . $course_id;
    	},
    	10,
    	2
    );
    
    add_filter(
    	'sensei_registration_url',
    	function( $registration_url, $redirect ) {
    		return 'http://registration.com?' . $redirect;
    	},
    	10,
    	2
    );
    
    add_filter(
    	'sensei_login_url',
    	function( $registration_url, $redirect ) {
    		return 'http://login.com?' . $redirect;
    	},
    	10,
    	2
    );
  • Create a course with lessons, and Learning Mode enabled.
    • In WP admin > Settings > General, enable the setting "Anyone can register".
    • Logged-out, access a lesson from the created course.
    • Make sure the "Take course" button was filtered to "lesson take" URL, and "Sign in" to "registration" URL.
    • In WP admin > Settings > General, disable the setting "Anyone can register".
    • Make sure not the "Sign in" link is filtered to "login" URL, and take course continues with the "lesson take" URL.
    • Log-in, access the lesson, and make sure that clicking on "Take course" will automatically enroll the user.
  • Create a course with lessons, and Learning Mode disabled.
    • Access a lesson from the created course logged-out and logged-in. Make sure in both situations you see the notice linking to the "lesson take" URL.

New/Updated Hooks

  • sensei_lesson_take_course_url - Filter the take course URL displayed in lessons. Notice that in Learning Mode, when user is logged-in, it will not use this filter and directly enroll the user in the course.
  • sensei_registration_url - Filter the registration URL.
  • sensei_login_url - Filter the login URL.

@renatho renatho changed the base branch from trunk to feature/post-code-freeze April 29, 2022 21:25
@renatho renatho self-assigned this Apr 29, 2022
@renatho renatho force-pushed the add/lesson-notices-filters branch 2 times, most recently from 5ca41b5 to 61e9491 Compare May 2, 2022 13:30
@renatho renatho force-pushed the add/lesson-notices-filters branch from 61e9491 to a90d9da Compare May 2, 2022 13:31
@renatho renatho added Hooks This change adds or modifies one or more hooks. [Type] Enhancement labels May 2, 2022
@renatho renatho added this to the 4.4.1 milestone May 2, 2022
@renatho renatho requested a review from a team May 2, 2022 15:08
@renatho renatho marked this pull request as ready for review May 2, 2022 15:08
Copy link
Member

@jom jom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and works well!

@renatho renatho merged commit c4bb1fb into feature/post-code-freeze May 9, 2022
@renatho renatho deleted the add/lesson-notices-filters branch May 9, 2022 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hooks This change adds or modifies one or more hooks. [Type] Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants