Display custom course field inside course pages

Home Forums Legacy Support Support queries How-to & Troubleshooting Display custom course field inside course pages

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #154132
    Dmit865
    Spectator
    Hi there! I know how to add a custom field for the course, but how do I display it's content (say, it will be a link) within the student course pages on units, quizzes and other pages? In fact, I would even considering displaying this custom link on the in-course sidebar menu that allows to navigate between course content. Thanks!
    #154204
    Diana
    Participant
    #154282
    Dmit865
    Spectator
    Thanks! How about doing the same with course-related field, not unit-related (so we don't need to input the same link for every unit, it is the same for the course).
    #154334
    Diana
    Participant
    @Dmit865, For the course sidebar, you can add a custom link which will be similar for all courses from wp-admin > LMS > Settings > Course Settings > Add Custom link
    #154402
    Dmit865
    Spectator
    @Diana, I would like to have a custom link like here https://wplms.io/support/knowledge-base/add-custom-content-in-attachment-area-of-units/ but not having to set it up for each unit individually. For that I need a way to access course-level field from the code provided on the link.
    #154446
    Diana
    Participant
    @Dmit865, add_filter('wplms_unit_metabox','wplms_custom_link'); function wplms_custom_link($link){ $prefix = 'vibe_'; $link[]=array( // Text Input 'label' => __('Link for playground','vibe-customtypes'), // <label> 'desc' => __('Put link on the playground button','vibe-customtypes'), // description 'id' => $prefix.'pglink', // field id and name 'type' => 'text' // type of field ); return $link;   }   //Shows button in attachment area in unit function bp_course_get_unit_attachments($id){ $link="https://wplms.io/support/knowledge-base/add-custom-content-in-attachment-area-of-units/";   if(isset( $link) &&  !empty($link)){ echo '<FORM> <INPUT Type="BUTTON" Value="CODEBASE" class="button" Onclick="window.location.href=\''.$link.'\'"> <style> .button{ height: 60px; width: 190px; font: 16px; } </style> </FORM>'; } } From this code you need not to set the link for each unit. All the unit will access the same link
    #154534
    Dmit865
    Spectator
    @Diana, Thanks! I am sorry for bothering you, but your solution, judging by the code above, offers the same pre-coded link for all courses (it is stored in $link variable). I need the link to be different for each course, preferably inputed by the instructor while editing the course. To bring some context: this link will point to a messenger chat of the course and it may differ quite a lot, so it's hard to hardcode. Better have instructors put the link to the chat in the custom course field, and then have this link displayed on all course elemenets like units, quizess, etc. The code provided here is almost perfect expect it adds a custom field for each unit and I would like to use a custom field for the whole course (because the chat link is the same for one course and I don't want instructor to have to copy it all the time for each unit. Thanks again!
    #154591
    Anshuman Sahu
    Keymaster
    Aplogies for the confusion . Please remove the above code if added and add this given code in your wplms-customizer.php file in wplms customizer plugin : //Add custom  metabox in unit add_filter('wplms_course_metabox','wplms_custom_link'); function wplms_custom_link($link){             $prefix = 'vibe_';             $link[]=array( // Text Input             'label' => __('Link for playground','vibe-customtypes'), // <label>             'desc' => __('Put link on the playground button','vibe-customtypes'), // description             'id' => $prefix.'pglink', // field id and name             'type' => 'text' // type of field                                 );             return $link;         } add_action('wplms_after_every_unit','bp_course_get_unit_attachments'); function bp_course_get_unit_attachments($id){     if(function_exists('bp_course_get_unit_course_id')){     $course_id = bp_course_get_unit_course_id($id);   }   $link=get_post_meta($course_id,'vibe_pglink',true);   if(isset( $link) &&  !empty($link)){     echo '<FORM>     <INPUT Type="BUTTON" Value="CODEBASE" class="button" Onclick="window.location.href=\''.$link.'\'">     <style>     .button{     height: 60px; width: 190px; font: 16px;     }     </style>     </FORM>';   }   }
    #154649
    Dmit865
    Spectator
    Worked, thanks! Only now the buttons is added two times for some reason. One after another in the attachments area...
    #154697
    Diana
    Participant
    @Dmit865, Can you please share the admin credentials with course URL in a private reply here to check this on your site. If you have added the code after removing the previous one then the button should appear only once
    #154755
    Dmit865
    Spectator
    This reply has been marked as private.
    #154864
    Diana
    Participant
    This reply has been marked as private.
    #154999
    Dmit865
    Spectator
    This reply has been marked as private.
    #155106
    Diana
    Participant
    @Dmit865, Will Let you know after fixing this on your site.
    #155692
    Dmit865
    Spectator
    @Diana, Any luck?
Viewing 15 posts - 1 through 15 (of 19 total)
  • The topic ‘Display custom course field inside course pages’ is closed to new replies.