Monday, May 20, 2024
WordpressWordpress HooksWp Tricks

How to add and delete user role in wordpress?

How to add and delete user role in wordpress?

Hello friends, welcome again on my blog. Today in this blog post, I am going to tell you, How to add and delete user role in wordpress?

WordPress User Roles Hooks

For WordPress lovers and beginners must check the below links:

Friends here is the working code snippet for How to add and delete user role in wordpress? and please use it carefully to avoid the mistakes:

1. Guys we need to add below code into our WordPress activated theme’s functions.php file:

Guys before run remove_role hook, we need to comment or delete add_role hook:

//Add new role hook

add_role("Youtuber", __("Youtuber"), array("read"=>true, "edit_posts"=>true));

//Delete role hook
//First you need remove or comment the add_role hook because if we will not delete or comment add_role hook then both add_role and remove_role will run same time with same name(Youtuber).



Now we are done friends. If you have any kind of query or suggestion or any requirement then feel free to comment below. There are lots of WordPress hooks and filters and we should use them rather then do custom code in theme core files or in plugins files.

Note: Friends, I just tell the basic setup and things, you can change the code according to your requirements. For better understanding must watch video above.
I will appreciate that if you will tell your views for this post.Nothing matters if your views will good or bad.



the authortherichpost
Hello to all. Welcome to Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 14, Angular 15, Angular 16, Angular 17, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.