A
athanasius
New Member
I am trying to figure out how I can create a custom display condition for templates. So for example, I am using LearnDash LMS and would like to specifically add a condition for users that are enrolled in a course. I dug into the ElementorPro Conditions classes to see how things are being done for the default conditions but I am not sure if I am on the right track. I've included the start of a class I have written to hopefully do the job, however I am not sure how/where to register this. Any help would be appreciated.
Thanks!
Thanks!
PHP:
class Course_By_Enrolled extends ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base {
private $post_type;
public static function get_type(){return 'singular';
}
public static function get_priority(){return 40;
}
public function __construct( $post_type ){parent::__construct();
$this->post_type = $post_type;
}
public function get_name(){return 'course_by_enrolled';
}
public function get_label(){return sprintf( __( 'Course By Enrolled', 'elementor-pro' ),$this->post_type->label );
}
public function check( $args = null ){if (is_singular('sfwd-courses')){$course_id = get_the_ID();
$user_id = get_current_user_id();
return is_user_logged_in() && sfwd_lms_has_access( $course_id, $user_id );
}
return false;
}
}