How to disable edit post option? [closed]

This will restrict all users, except admins to edit a post after one day. You can, however, change the allowed user roles or time by simply tweaking the code.

function wpse405644_restrict_editing() {
    
    $screen = get_current_screen();
    if ( $screen->base == 'post' && $screen->post_type == 'courses' ) {
        $post = get_post($_GET['post']);
        $user = wp_get_current_user();
        if ( !in_array( 'administrator', $user->roles ) ) {
            if ( $post->post_status == 'publish' && (strtotime( $post->post_date ) < strtotime( '-1 day' )) ) {
                wp_die( 'You are not allowed to edit this post.');
            }
        }
    }
}
add_action( 'current_screen', 'wpse405644_restrict_editing' );  

You may need to change the CPT with your own.

EDIT (Frontend Restriction)

This code goes in your theme’s functions.php.

function wpse405644_is_frontend_editing_allowed () {
    
    if ( isset($_GET['course_ID']) && !empty($_GET['course_ID']) ) {
        $post = get_post($_GET['course_ID']);
        $user = wp_get_current_user();
        if ( !in_array( 'administrator', $user->roles ) ) {
            if ( $post->post_status == 'publish' && (strtotime( $post->post_date ) < strtotime( '-1 day' )) ) {
                return false;
            }
        }
    }
    
    return true;
}

Now at the create course template, wrap the whole content section with the conditional function.

<?php
defined( 'ABSPATH' ) || exit;

get_tutor_header( true );

    if ( wpse405644_is_frontend_editing_allowed() ) {
        
        // The content BETWEEN get_tutor_header and get_tutor_footer goes here.
        
        
    } else {
        echo '<h2>You are not allowed to edit this post.</h2>';
    }
<?php get_tutor_footer( true );

This will show a message when the user isn’t allowed to edit course.