You should not use raw SQL to modify roles and capabilities, it is very bad practice, and unnecessary.
Instead, use the roles API, e.g.
$role = get_role( 'subscriber' );
$role->add_cap( 'read' );
Or to add it to a specific user:
$user = new WP_User( $user_id );
$user->add_cap( 'read' );
Likewise you can remove a capability from a role:
$role = get_role( 'subscriber' );
$role->remove_cap( 'read' );
Related Posts:
- the_date() not working
- How to return number of found rows from SELECT query
- Check php version before theme activation
- Extract the first oembed url inserted on the content of a post
- WP API V2 returning Invalid User ID
- Why does $_SESSION only work when I am logged in?
- How to make an meta_query optional?
- How to show only parents subpages of current page item in vertical menu?
- How to use copy() function and paste file in /wp-content/themes directory
- PHP calling AJAX function that relies on passed PHP function values not working
- Sanitize get_query_var() url parameters
- I think emoji are killing my WordPress site… How can I debug?
- WordPress Ajax Data problem
- Hiding a php element from mobile browsers
- PHP/MySQL issues when running WP on EC2 cloud [closed]
- How to safely remove the footer (twentytwenty)
- ajax_object is not defined when ajax calls the function
- How do I fetch all comments per post via WP REST API?
- When using the_author hook, how can I determine the PHP file that generates each call to `the_author()`?
- wp_insert_post not working
- Add htaccess rules with insert_with_markers at beginning of htaccess
- Using More Tag in Combination with the_excerpt
- Add a custom stylesheet for BlackBerry
- Custom theme: Alternatives to long list of ‘include’ in functions.php
- Reordering Buddy Press profile navigation [closed]
- How can I get the total number of installed importers?
- Why my filterable portfolio page work not perfectly between slug button and slug output WORDRPESS?
- MetaBox body is not showing (the callback function)
- How to make products with no cost in WooCommerce
- Pass php dynamic variable to shortcode
- Insert term and child term from frontend
- Help with .htaccess and Login with Subfolders
- Do wordpress create a new file for each new post?
- Catchable fatal error on 3.6 update
- AJAX – Returning Two JSON Objects with One PHP Function
- How to show a users bio on a page
- How can I access string value in an array?
- Defined WordPress Memory Limit to Unlimited
- Add Ajax Hooks and Call from Custom Template PHP
- Why in my theme I can’t see all the statics content under the posts?
- Display all pages – in order
- Get Page ID from Backend
- Design with Elementor and code the rest?
- Can a plugin redirect product page based on IF condition?
- How set a custom URL for a new theme file in WP?
- How to use mysql LIKE with wpdb?
- Get all posts as an array ID => Name
- How to store multiple custom meta box
- woocommerce related product title length
- How to get post ID from button and pass title to Modal
- file_get_contents(includes_url( ‘/js/jquery/jquery.js’ )); not working
- cURL error 6 on news area, and also won’t auto update
- Do not duplicate posts with multiple categories in multiple loops
- Can’t change website Title on wordpress
- How to manually trigger a redirect to another page without changing the url address?
- How to use title attributes in sidebar widget?
- Query for user roles
- How to get my [shortcode] rendered on the home page, other pages are fine
- Php file that doesn’t recognize wordpress functions
- Set cookie for visitor
- Wp favorites posts by specific category? [closed]
- Use of antispambot with $curauth->email
- Add a suffix to the image in the_content()
- How to add JS script in specific pages in WordPress?
- Fatal error login WordPress [duplicate]
- Pagination contents not changing in Front page WordPress
- add role on WordPress in PHP on a second database
- How to select post ID for given parent name with nested prepared queries?
- Enqueue assets from multiple directories using add_action/do_action
- Add code to the header of posts by particular author
- Running a PHP SQL script on a wordpress page
- Can I disable auto increment of WordPress Posts Database to utilize previously deleted records?
- Changing Date Format on Custom Meta Data w/shortcode call
- How to apply ‘add two more posts’ to media content?
- How to disable sub menu items from being created?
- Access to “My Site” is missing from the admin bar
- Unable to insert current username into custom table through html form
- add ‘publish metabox’ to Gravity forms edit page/form area
- How to redirect (301) trashed post to it’s parent taxonomy TERM ARCHIVE instead of 404 page
- load a wordpress page into another wordpress page using iframe
- style.min.css code issue
- How do I modify the Previous and Next Page posts on blog pages to include “previous” and “next” before the links?
- How can i iterate through this shortcode array?
- How do I prevent a folder from reappearing in my home directory?
- How to detect and make links nofollow in author description
- Making my own admin panel for WordPress
- Styling admin page rows in order of importance (checkboxes)
- On selecting shortcode generate selected shortcode table inside page editor worrdpress
- WordPress plugin creating sidebar on the theme/page
- Using existing widget code! [closed]
- Pagenav Not appearing on custom Template
- How To Customize Position of »add to cart« of WooCommerce on Product Page [closed]
- Display wordpress post to static website in the footer
- PHP Puzzle: Unique Styles with PHP loop
- My title is showing after the shortcode
- Display Sale Price Before Regular Price (WooCommerce)
- Adding multiple conditional tags in a function?
- Edit Error Page style
- PHP $_SESSION array – only showing current index
- How can I use AJAX in child theme template?