Step 1 Adding a Plugin

function my_admin_menu() {
    $page_title = 'Clear Stock';
    $menu_title = 'Clear Stock';
    $capability = 'manage_options';
    $menu_slug = '/clear_stock';
    $function = 'clear_stock';
    $icon_url = '';
    $position = -1;
    add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position);
}
add_action( 'admin_menu', 'my_admin_menu' );

WordPress Update meta_value by meta_key

// Clear Stock
function clear_current_stock(){ 
// Declare the $wpdb var
    global $wpdb;
// Run My SQL Query (My Query is setting the meta value for stock to zero)
    $wpdb->query("UPDATE wp_postmeta SET meta_value = 0 WHERE meta_key = '_stock'");
// Check if there were any errors or if my query was successful.
    if ( is_wp_error( $wpdb ) ) {
         echo $wpdb->get_error_message();
    }
    else {
         echo 'true';
    }
}

Then you can call the function like this

<?php clear_current_stock(); ?>

Check User Role ( if statement included )

<?php
  $user_id = get_current_user_id();
  if (!empty($user_id)) {
  $user = wp_get_current_user();
  $role = ( array ) $user->roles;
  // echo $role[0];
  if ($role[0] == 'free-client' OR $role[0] == 'administrator') {
    //code here...
  }
  }
?>

WordPress Add Custom Post Type With Category

// Custom Post 1
    register_post_type( 'courses',
        array(
            'labels' => array(
                'name' => __( 'Courses' ),
                'singular_name' => __( 'Course' )
            ),
        'public' => true,
        'has_archive' => true,
        'supports' => array('title', 'editor', 'thumbnail'),
        'show_ui' => true
        )
    );
 register_taxonomy('courses_categories', 'courses', ['label' => 'Courses Categories','hierarchical' => true]);

NB! (The hierarchical array item is Important)
,’hierarchical’ => true

WordPress create a shortcode

Inside your themes functions.php add the below snippet and fill out the placeholders.

############################################################################
//////////////////////////////////////
// This is your shortcode. You reference it like you see below with the square brackets.
// [shortcode_name_here]
//////////////////////////////////////
function echo_shortcode_function_name(){
    ob_start();
    include '/path to our file';
    return ob_get_clean();
}
add_shortcode( 'shortcode_name_here', 'echo_shortcode_function_name');
############################################################################

Now reference your shortcode and it should load no issues if your file references are correct.