How to get the WordPress user role from the database

  Рет қаралды 1,819

Joshua Herbison

Joshua Herbison

Күн бұрын

A WordPress tutorial on how to get the user's role from the database.
#wordpress #wordpressTutorial #wordpressDevelopment

Пікірлер: 14
@jherbison
@jherbison 3 жыл бұрын
I do a lot of database queries and it helps a lot to be able to connect the user to the user role in a database query.
@Daud181
@Daud181 3 жыл бұрын
Cool great video
@jherbison
@jherbison 3 жыл бұрын
Thanks.. It is still processing I think.
@viktorshevchenko3888
@viktorshevchenko3888 3 жыл бұрын
Thank you so much for this video with detailed explanations.
@jherbison
@jherbison 3 жыл бұрын
You’re welcome. Thank you for watching and commenting.
@pkg2885
@pkg2885 2 жыл бұрын
Thank you for all your videos ... ^^ Very much enjoy learning code from you. I am now subscribed for your channel ^_^
@jamllesol8796
@jamllesol8796 2 жыл бұрын
Haven't tried it but this is amazing
@theman7050
@theman7050 3 жыл бұрын
Joshua, under what circumstances is it ok to query the database back and forth like this? I mean ive heard that repeated queries directly to database affect site speed. Is it correct? Coz I run into situations where I cannot make CPT for everything and database tables appear to be more feasible. So how to draw the line there?
@jherbison
@jherbison 3 жыл бұрын
Thank you for the question. WordPress already uses over 40 database queries for their default theme page load. I like to limit the queries as much as possible. I remove as much of WordPress default queries to get it down to about 19 for a page load. So I feel adding a couple of my own queries is fine. Plus, I like speed and this is the reason I do my own queries. If you do a generic get_user_by database query, it return the entire user information as an object. I slim down the query by only requesting what I need from the user information. Hope that helps.. Thank you for watching and commenting.
@raj080288
@raj080288 3 жыл бұрын
What extension are you using to pre supply the php snippet?
@jherbison
@jherbison 3 жыл бұрын
I create most of my snippets myself. I did a video a couple of weeks ago on sublime text snippets. kzbin.info/www/bejne/iGe0hWyllrJqfLs
@jherbison
@jherbison 3 жыл бұрын
Thank you for watching and commenting.
@raj080288
@raj080288 3 жыл бұрын
@@jherbison thank.you for providing such great content. Looking forward to more videos
@stefanpfadt4353
@stefanpfadt4353 2 жыл бұрын
Hi great video! I am a non-coder and wwant to ask how you would go about this scenario: I have a search form on my website and I want specific search fields only visible to certain user roles, so subscriber can only see first search field, contributor can see 2 and so on. What steps would I have to take? Code/function wise? I appreciate any input or suggestion ;)
Using GET or POST, When, Why and How to get the data in PHP
14:32
Joshua Herbison
Рет қаралды 750
An Unknown Ending💪
00:49
ISSEI / いっせい
Рет қаралды 49 МЛН
Touching Act of Kindness Brings Hope to the Homeless #shorts
00:18
Fabiosa Best Lifehacks
Рет қаралды 19 МЛН
The Joker wanted to stand at the front, but unexpectedly was beaten up by Officer Rabbit
00:12
Create a Shortcode Plugin that uses ob_start() function to return data
15:19
Create WordPress Custom User Role for Custom Post Type
47:48
Vicode Media
Рет қаралды 7 М.
No, Einstein Didn’t Solve the Biggest Problem in Physics
8:04
Sabine Hossenfelder
Рет қаралды 264 М.
Turns out REST APIs weren't the answer (and that's OK!)
10:38
Dylan Beattie
Рет қаралды 158 М.
What is the difference between JSON and PHP Serialize
18:50
Joshua Herbison
Рет қаралды 1,5 М.
WordPress Tutorial on how to create a GDPR WordPress Plugin
1:37:05
Joshua Herbison
Рет қаралды 3,6 М.
I redesigned YOUR websites
20:44
DesignSpo
Рет қаралды 9 М.