How to give members access to their own protected page?

funtion add_profile_page(){ 
    $title_of_page = "page name";
    if( null == get_page_by_title( $title_of_page ) ) {
            $post_id = wp_insert_post(
                array(
                    'comment_status'    =>  'closed',
                    'ping_status'       =>  'closed',
                    'post_author'       =>  '1',
                    'post_name'         =>  'namehere',
                    'post_title'        =>  $title_of_page,
                    'post_status'       =>  'publish',
                    'post_type'         =>  'page'

                )
            );
            update_post_meta($post_id, '_wp_page_template', 'mycustomprofile');
        }  
}

add_filter( 'after_setup_theme', 'add_profile_page' );

your template page

/*
    Template Name : mycustomprofile
*/


// Do whatever you want here 

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)