Problem:
Perform a conditional action based on the user role based on the user name that was provided in the URL.
Solution:
In order to get this done I would recommend the use of a custom shortcode.
To get the user role from the user name in the url you can use the shortcode below.
// Add Shortcode function wp_get_user_role( $atts ) { // Attributes $atts = shortcode_atts( array( 'username' => '', ), $atts ); $user_meta=get_user_by('login',$atts['username']); $user_roles=$user_meta->roles; return $user_roles[0]; } add_shortcode( 'wp_get_user_role', 'wp_get_user_role' );
The shortcode is used like this
[wp_get_user_role username=' [wpv-search-term param='church']']
Where you can use the [wpv-search-term param='url-param'] to get the username from the param.
From there you can add this shortcode to the conditional statement.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 14:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Jamaica (GMT-05:00)
This topic contains 16 replies, has 2 voices.
Last updated by 5 years, 7 months ago.
Assisted by: Shane.