Change custom post type slug from plugin options

The best way to do it is right before you display the options page. Right before your call to settings_fields, add this:

if( isset( $_REQUEST['settings-updated'] ) )
    flush_rewrite_rules();

Remove the flush_rewrite_rules from your other function and that should do the trick. Its worked for me.

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