WordPress Codesnippets

add roles

				
					
				
			

, otherwise posts are only saved as drafts
‘edit_themes’ => false, // false denies this capability. User can’t edit your theme
‘install_plugins’ => false, // false denies this capability. User can’t install plugins
‘update_plugin’ => false, // false denies this capability. User can’t update plugins
‘update_core’ => false // false denies this capability. User can’t perform core updates
));

This code creates a new user role with the name “role_name” and the display name “Display Name”. This role has the following capabilities: reading and editing their own posts and pages, as well as the posts and pages of others; creating new posts; managing post categories; and publishing posts. This role does not have the capabilities to edit themes, install plugins, or update plugins or the WordPress core.

Was this code snippet helpful?
YesNo

Leave a Reply

Your email address will not be published. Required fields are marked *

Programmatically save post

This code creates a WordPress post with the values of the ‘post_title’ and ‘post_content’ variables. It sets the post status to ‘publish’ and the author

Read More »

Create order programmatically

This code creates a new post in the WordPress database with post type ‘shop_order’, post title ‘Order #12345’, post status ‘wc-processing’, and ping status ‘closed’.

Read More »