{"id":323,"date":"2020-05-21T18:00:54","date_gmt":"2020-05-21T18:00:54","guid":{"rendered":"https:\/\/www.techcrm.in\/blogs\/?p=323"},"modified":"2023-01-07T17:24:47","modified_gmt":"2023-01-07T11:54:47","slug":"get-the-current-user-role-sugarcrm-suitecrm","status":"publish","type":"post","link":"https:\/\/www.techcrm.in\/blogs\/get-the-current-user-role-sugarcrm-suitecrm\/","title":{"rendered":"Get the Current User Role &#8211; SugarCRM \/ SuiteCRM"},"content":{"rendered":"\n<p>There was a requirement from client where he wants validation based on user role. So we need to check login user (current user) role name and put validation on it. This can be achieved by using below simple steps.<\/p>\n\n\n\n<p>we can get the current user role using the following code,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>global $current_user;\ninclude_once(\u2018modules\/ACLRoles\/ACLRole.php\u2019);\n$ACLRole = new ACLRole();\n$roles = $ACLRole->getUserRoleNames($current_user->id);\necho \"&lt;pre>\";\nprint_r($roles);<\/code><\/pre>\n\n\n\n<p>Hope you find this blog post helpful.<\/p>\n\n\n\n<p>Feel free to add comments and queries, that helps us to improve the quality of posts.<\/p>\n\n\n\n<p>You can contact us at&nbsp;<a rel=\"noreferrer noopener\" href=\"mailto:contact@urdhva-tech.com\" target=\"_blank\">info@techcrm.in<\/a><\/p>\n\n\n\n<p>Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There was a requirement from client where he wants validation based on user role. So we need to check login user (current user) role name and put validation on it. This can be achieved by using below simple steps. we can get the current user role using the following code, Hope you find this blog [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,9],"tags":[86,12,13,85],"class_list":["post-323","post","type-post","status-publish","format-standard","hentry","category-sugarcrm","category-suitecrm","tag-current-user","tag-sugarcrm","tag-suitecrm","tag-user-role"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Get the Current User Role - SugarCRM \/ SuiteCRM - TechCRM<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.techcrm.in\/blogs\/get-the-current-user-role-sugarcrm-suitecrm\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get the Current User Role - SugarCRM \/ SuiteCRM - TechCRM\" \/>\n<meta property=\"og:description\" content=\"There was a requirement from client where he wants validation based on user role. So we need to check login user (current user) role name and put validation on it. This can be achieved by using below simple steps. we can get the current user role using the following code, Hope you find this blog [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.techcrm.in\/blogs\/get-the-current-user-role-sugarcrm-suitecrm\/\" \/>\n<meta property=\"og:site_name\" content=\"TechCRM\" \/>\n<meta property=\"article:published_time\" content=\"2020-05-21T18:00:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-07T11:54:47+00:00\" \/>\n<meta name=\"author\" content=\"Navin Rakhonde\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Navin Rakhonde\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/get-the-current-user-role-sugarcrm-suitecrm\/\",\"url\":\"https:\/\/www.techcrm.in\/blogs\/get-the-current-user-role-sugarcrm-suitecrm\/\",\"name\":\"Get the Current User Role - SugarCRM \/ SuiteCRM - TechCRM\",\"isPartOf\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#website\"},\"datePublished\":\"2020-05-21T18:00:54+00:00\",\"dateModified\":\"2023-01-07T11:54:47+00:00\",\"author\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/get-the-current-user-role-sugarcrm-suitecrm\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.techcrm.in\/blogs\/get-the-current-user-role-sugarcrm-suitecrm\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/get-the-current-user-role-sugarcrm-suitecrm\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.techcrm.in\/blogs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SugarCRM\",\"item\":\"https:\/\/www.techcrm.in\/blogs\/category\/sugarcrm\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Get the Current User Role &#8211; SugarCRM \/ SuiteCRM\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#website\",\"url\":\"https:\/\/www.techcrm.in\/blogs\/\",\"name\":\"TechCRM\",\"description\":\"Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.techcrm.in\/blogs\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc\",\"name\":\"Navin Rakhonde\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g\",\"caption\":\"Navin Rakhonde\"},\"sameAs\":[\"https:\/\/www.techcrm.in\/\"],\"url\":\"https:\/\/www.techcrm.in\/blogs\/author\/navin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Get the Current User Role - SugarCRM \/ SuiteCRM - TechCRM","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.techcrm.in\/blogs\/get-the-current-user-role-sugarcrm-suitecrm\/","og_locale":"en_US","og_type":"article","og_title":"Get the Current User Role - SugarCRM \/ SuiteCRM - TechCRM","og_description":"There was a requirement from client where he wants validation based on user role. So we need to check login user (current user) role name and put validation on it. This can be achieved by using below simple steps. we can get the current user role using the following code, Hope you find this blog [&hellip;]","og_url":"https:\/\/www.techcrm.in\/blogs\/get-the-current-user-role-sugarcrm-suitecrm\/","og_site_name":"TechCRM","article_published_time":"2020-05-21T18:00:54+00:00","article_modified_time":"2023-01-07T11:54:47+00:00","author":"Navin Rakhonde","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Navin Rakhonde","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.techcrm.in\/blogs\/get-the-current-user-role-sugarcrm-suitecrm\/","url":"https:\/\/www.techcrm.in\/blogs\/get-the-current-user-role-sugarcrm-suitecrm\/","name":"Get the Current User Role - SugarCRM \/ SuiteCRM - TechCRM","isPartOf":{"@id":"https:\/\/www.techcrm.in\/blogs\/#website"},"datePublished":"2020-05-21T18:00:54+00:00","dateModified":"2023-01-07T11:54:47+00:00","author":{"@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc"},"breadcrumb":{"@id":"https:\/\/www.techcrm.in\/blogs\/get-the-current-user-role-sugarcrm-suitecrm\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.techcrm.in\/blogs\/get-the-current-user-role-sugarcrm-suitecrm\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.techcrm.in\/blogs\/get-the-current-user-role-sugarcrm-suitecrm\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.techcrm.in\/blogs\/"},{"@type":"ListItem","position":2,"name":"SugarCRM","item":"https:\/\/www.techcrm.in\/blogs\/category\/sugarcrm\/"},{"@type":"ListItem","position":3,"name":"Get the Current User Role &#8211; SugarCRM \/ SuiteCRM"}]},{"@type":"WebSite","@id":"https:\/\/www.techcrm.in\/blogs\/#website","url":"https:\/\/www.techcrm.in\/blogs\/","name":"TechCRM","description":"Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.techcrm.in\/blogs\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc","name":"Navin Rakhonde","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g","caption":"Navin Rakhonde"},"sameAs":["https:\/\/www.techcrm.in\/"],"url":"https:\/\/www.techcrm.in\/blogs\/author\/navin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/comments?post=323"}],"version-history":[{"count":4,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/323\/revisions"}],"predecessor-version":[{"id":1374,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/323\/revisions\/1374"}],"wp:attachment":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/media?parent=323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/categories?post=323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/tags?post=323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}