Add custom content in attachment area of units

In this tip we will try to add a custom button with external link.

1. Add this code in your wp-content/plugins/wplms-customizer/wplms-customizer.php.

//Add custom  metabox in unit
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=get_post_meta($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>';
}
}

This code will create a metabox in unit settings( in wp-admin edit unit page):

Now you can put a link in “link” metabox in unit settings from back-end (i.e. wp-admin edit unit page) and that link will be showed on the button.