I am using WPLMS theme for a course management website. I am using following code to display a button in the details page.
add_filter('wplms_before_course_description','custom_add_second_button');
function custom_add_second_button($course_details){
$custom_link = get_post_meta(get_the_ID(),'Custom_button_link',true);
if(isset($custom_link)){
echo '<a class="full button" href="'.$custom_link.'"><span class="vicon vicon-shopping-cart"></span> Buy This Course</a>';
return $course_details;
}
return $course_details;
}
This is to show a custom add to cart button beside the title of the course. Now what I want is if a student has already purchased this course, this button will not come up. Kindly help me to achieve my goal please. Thanks in advance.
2
Answers
You can use WC
wc_customer_bought_product()
function to check whether the customer already bought it or not.USEFUL LINKS.
You can use the function bp_course_is_member($course_id,$user_id)) to check if the user is already a member of the course.