Last active
July 2, 2017 14:01
-
-
Save AladinDridi/14222f3a46c726302b99e2a635ab23af to your computer and use it in GitHub Desktop.
shortcode for enroll users to course -learndash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function my_vc_shortcode( $atts ) { | |
global $current_user; | |
get_currentuserinfo(); | |
switch (true) { | |
case ( user_can( $current_user, "7eme") && is_user_logged_in() && function_exists('pmpro_hasMembershipLevel') && @!pmpro_hasMembershipLevel() ): | |
$course_id = learndash_get_course_id( $post_id ); | |
$user = get_current_user_id(); | |
return ld_update_course_access($user, $course_id=111, $remove = false); | |
break; | |
} | |
} | |
add_shortcode( 'my_vc_php_output', 'my_vc_shortcode'); | |
// add shortcode [my_cd_php_output] to any page // advice to user visual composer text block // thanks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if didnt work
add this code in your function.php of your theme , i recommand to you this plugin code for guarantee that the code will be add correctly
function my_vc_shortcode( $atts ) {
global $current_user;
get_currentuserinfo();
switch (true) {
case ( user_can( $current_user, "7eme") && is_user_logged_in() && function_exists('pmpro_hasMembershipLevel') && @!pmpro_hasMembershipLevel() ):
$course_id = learndash_get_course_id( $post_id );
$user = get_current_user_id();
return ld_update_course_access($user, $course_id=111, $remove = false);
break;
}
}
add_shortcode( 'my_vc_php_output', 'my_vc_shortcode');
From here, add a Visual Composer text block with your newly created shortcode called within it. For this guide the shortcode is [my_vc_php_output]: