Access to option page by role/capability

You should be able to do this via the option_page_capability_{$option_page} hook – like: function wpse151616_grant_access_to_options_page_for editors() { return ‘edit_posts’; } add_filter( ‘option_page_capability_rooster’, ‘wpse151616_grant_access_to_options_page_for editors’ ); For possible return values take a look at Roles and Capabilities. The variable part – {$option_page} – of the hook name is substituted by the menu slug – $menu_slug – … Read more

How to get only 1 role from user

Try this: if ( !empty( $user->roles ) && is_array( $user->roles ) ) { $first_role = array_shift($user->roles); echo $first_role; } Function array_shift obtains the first element of the $user->roles array.

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