Button on lead 'create' in that 'opportunity' option how to hide 'opportunity'

There is one button on lead ‘create’ in that ‘opportunity’ option how to hide ‘opportunity’ option for specific user

Don’t give the permission of Opportunity doctype to user.

Then Button will automatically not show to user

Check your old post: Search results for 'hide button @Rahul7218 order:latest' - Frappe Forum

set the condition like

if (frappe.session.user == "user1@testmail.com")

hi @NCP
i have used this script and its works

frappe.ui.form.on(‘Lead’, {
refresh(frm) {
setTimeout(() => {
frm.remove_custom_button(‘Opportunity’, ‘Create’);

    }, 10);
}

});

i want to hide opportunity option for those users who have ‘sub-sales person’ Role
how to give this condition

Please apply it.

frappe.ui.form.on('Lead', {
    refresh(frm) {
        if (frappe.user.has_role('Sub-Sales Person')) {
            setTimeout(() => {
                frm.remove_custom_button('Opportunity', 'Create');
            }, 10);
        }
    }
});

Check the role name and set it in the script.

thank you @NCP