Restrict Stock Entry submission based on Purpose & role

I would like to restrict user to submit Stock Entry for material transfer purpose to only the user with role of Stock Transfer Approval. Any help will be much appreciated, here is my code.

cur_frm.cscript.custom_before_submit = function(doc) {
if(frm.doc.purpose==“Material Transfer” && user.role_profile_name!=“Stock Transfer Approval”) {
frappe.msgprint(“You are not allowed to submit Material Transfer”);
return false;