Pmpro Courses Shortcodes

Below, you’ll find a detailed guide on how to add the Pmpro Courses Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Pmpro Courses Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Pmpro Courses Plugin and the shortcodes it provides:

Plugin Icon
Premium Courses & eLearning with Paid Memberships Pro for LearnDash, LifterLMS, Sensei LMS & TutorLMS

"Premium Courses & eLearning with Paid Memberships Pro is an advanced plugin for LearnDash, LifterLMS, Sensei LMS & TutorLMS. It enhances your site's eLearning capabilities and offers premium courses."

★★★★★ (1) Active Installs: 3000+ Tested with: 6.3.2 PHP Version: 7.0
Included Shortcodes:
  • [pmpro_all_courses]
  • [pmpro_my_courses]

Pmpro Courses [pmpro_all_courses] Shortcode

The PMPro Courses shortcode is a powerful tool that allows you to display all courses on your website. Using the ‘limit’ attribute, you can control the number of courses shown. If no limit is set, all courses will be displayed. The shortcode retrieves the courses via the pmpro_courses_get_courses function and returns them in HTML format.

Shortcode: [pmpro_all_courses]

Parameters

Here is a list of all possible pmpro_all_courses shortcode parameters and attributes:

  • limit – Sets the maximum number of courses to display

Examples and Usage

Basic example – Display all courses without any limit.

[pmpro_all_courses /]

Advanced examples

Display a specific number of courses by setting the limit attribute. For instance, if you want to display only the first 5 courses, you can do so by using the ‘limit’ parameter as shown below:

[pmpro_all_courses limit=5 /]

Similarly, if you want to display the first 10 courses, you can adjust the ‘limit’ parameter accordingly:

[pmpro_all_courses limit=10 /]
These examples show how you can use the ‘pmpro_all_courses’ shortcode to display courses on your website. The ‘limit’ parameter allows you to control the number of courses displayed, providing flexibility based on your specific needs.

PHP Function Code

In case you have difficulties debugging what causing issues with [pmpro_all_courses] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'pmpro_all_courses', 'pmpro_courses_shortcode_all_courses' );

Shortcode PHP function:

                    function pmpro_courses_shortcode_all_courses( $atts ) {

	extract( shortcode_atts( array(
		'limit' => -1,
	), $atts));

	$course_limit = isset( $atts['limit'] ) ? intval( $atts['limit'] ) : -1;

	$courses = pmpro_courses_get_courses( $course_limit );

	return pmpro_courses_get_courses_html( $courses );

}
                    

Code file location:

pmpro-courses/pmpro-courses/includes/shortcodes/all-courses.php

Pmpro Courses [pmpro_my_courses] Shortcode

The pmpro-courses plugin shortcode ‘pmpro_my_courses’ displays a user’s courses. If the user is not logged in, it prompts them to log in. The ‘limit’ attribute can be set to limit the number of displayed courses.

Shortcode: [pmpro_my_courses]

Parameters

Here is a list of all possible pmpro_my_courses shortcode parameters and attributes:

  • limit – defines the maximum number of courses to display

Examples and Usage

Basic example – Displays the courses of the logged-in user without any limit.

[pmpro_my_courses /]

Advanced examples

Limit the number of courses displayed for the logged-in user. In this example, only the first 5 courses will be shown.

[pmpro_my_courses limit=5 /]

Display all courses for the logged-in user, but only if the user is logged in. If not logged in, a login link is displayed instead.

[pmpro_my_courses limit=-1 /]

Please note that the ‘limit’ attribute determines the number of courses that will be displayed. If you set it to -1, all courses will be displayed. If you set it to a positive number, only that many courses will be displayed. If the user is not logged in, a login link will be displayed instead of the courses.

PHP Function Code

In case you have difficulties debugging what causing issues with [pmpro_my_courses] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'pmpro_my_courses', 'pmpro_courses_shortcode_my_courses' );

Shortcode PHP function:

                    function pmpro_courses_shortcode_my_courses( $atts ) {

	extract( shortcode_atts( array(
		'limit' => -1,
	), $atts));

	ob_start();

	if ( ! is_user_logged_in() ) {
		return '<p><a href="<?php echo esc_url( wp_login_url() ); ?>">' . esc_html_e( 'Log in to view your courses »', 'paid-memberships-pro') . '</a></p>';
	}

	$course_limit = isset( $atts['limit'] ) ? intval( $atts['limit'] ) : 5;

	$courses = pmpro_courses_get_courses( $course_limit, get_current_user_id() );

	return pmpro_courses_get_courses_html( $courses );
}
                    

Code file location:

pmpro-courses/pmpro-courses/includes/shortcodes/my-courses.php

Conclusion

Now that you’ve learned how to embed the Pmpro Courses Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *