Display User role through dynamic content

Hi, I need to know how to display current (looged in) user ROLE.
use case: I’m assigning a class to an element where dynamic content is being used to give the class either .administrator or .subscriber etc. depending which user is logged in.
When I use the dynamic content for usermeta > wp_capabilities it just displays a 1

Cheers,
David

Hey David,

There is no Dynamic Content that can display the user role. I’d recommend that you instead create element variations using the the User Role Condition to display an element based on its user role.

Hope that helps.

Hey Christian,

Thanks for your response. I’ve attached a quick Loom on the dynamic content for current User Role. As you can see it does say administrator in the dynamic content, I’m just not sure how to get this to display: https://www.loom.com/share/2ba967fff17b4ec6a63b1ea73e564b11
I have a feeling this is something to do with the provider needing adjusting.

Unfortunately I can’t use conditions which would make my life so much simpler. This is because the page is actually being embedded into another site through a JS .load method which stuffs up the conditions functionality.

Please let me know if the User Role stuff is possible.

Cheers,
David

Hello David,

You are looking at the wp_capabilities value incorrectly. You have this:
a:1:{s:13:"administrator";b:1;}

It means, a = array, s = string, b = boolean :

array(1) {
    ["administrator"]=>
    bool(true)
}

If you are trying to display the current user role, perhaps this articles can help you instead.

Best Regards.

Thanks for the response. I assumed it was possible through dynamic content, but I’ve used a workaround.

Cheers,
David

Hi David,

Thanks for letting us know.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.