Title: Shortcode getting rua_get_user_levels
Last modified: August 1, 2018

---

# Shortcode getting rua_get_user_levels

 *  Resolved [ggarmory](https://wordpress.org/support/users/ggarmory/)
 * (@ggarmory)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/shortcode-getting-rua_get_user_access/)
 * I was wondering if it is possible to create a shortcode to display the level 
   access levels from the current user front-end, and if possible how.
 * The shortcode would, for example, display the following: level_1, level_2, level_5
 * Thanks in advance!
    -  This topic was modified 7 years, 10 months ago by [ggarmory](https://wordpress.org/support/users/ggarmory/).

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Joachim Jensen](https://wordpress.org/support/users/intoxstudio/)
 * (@intoxstudio)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/shortcode-getting-rua_get_user_access/#post-10587804)
 * This is not currently possible, but thank you for your feedback and suggestion!
 * Can you explain your use case in more detail? Then it will be easier for me to
   see how I can implement this in a flexible way 🙂
 *  Thread Starter [ggarmory](https://wordpress.org/support/users/ggarmory/)
 * (@ggarmory)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/shortcode-getting-rua_get_user_access/#post-10602848)
 * [https://github.com/intoxstudio/restrict-user-access/blob/master/api/level.php ](https://github.com/intoxstudio/restrict-user-access/blob/master/api/level.php)
 * I would like to retrieve the access levels of the current user. I have created
   my own plugin/addon to collect the current user ID with the intention to use 
   it in combination with your API.
 * I have been trying to use the level.php file, specificly the one function below:
 * /**
    * API to get user levels * * [@since](https://wordpress.org/support/users/since/)
   0.9 * [@param](https://wordpress.org/support/users/param/) int $user_id * [@param](https://wordpress.org/support/users/param/)
   boolean $hierarchical * [@param](https://wordpress.org/support/users/param/) 
   boolean $synced_roles * [@param](https://wordpress.org/support/users/param/) 
   boolean $include_expired * [@return](https://wordpress.org/support/users/return/)
   array */ function rua_get_user_levels( $user_id = null, $hierarchical = true,
   $synced_roles = true, $include_expired = false) { return RUA_App::instance()-
   >level_manager->get_user_levels($user_id,$hierarchical,$synced_roles,$include_expired);}
 * For some odd reason, it returns the text “array” not actually an array of user
   access levels.
 * I am calling the function with the following line, am I doing something wrong?:
 * $current_user_levels = rua_get_user_levels($current_user_id);
 * Kind Regards,
 *  Thread Starter [ggarmory](https://wordpress.org/support/users/ggarmory/)
 * (@ggarmory)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/shortcode-getting-rua_get_user_access/#post-10603337)
 * I was being stupid, I found out how to do it! For all the newbie scripters out
   there like me:
 * add_action(‘init’, ‘rua_get_user_levels_custom’);
 * function rua_get_user_levels_custom($user_id){
    $user_id = get_current_user_id();
   $user_levels = rua_get_user_levels($user_id); echo implode(“,”, $user_levels );}

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Shortcode getting rua_get_user_levels’ is closed to new replies.

 * ![](https://ps.w.org/restrict-user-access/assets/icon-256x256.png?rev=1815922)
 * [Restrict User Access - Ultimate Membership & Content Protection](https://wordpress.org/plugins/restrict-user-access/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/restrict-user-access/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/restrict-user-access/)
 * [Active Topics](https://wordpress.org/support/plugin/restrict-user-access/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/restrict-user-access/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/restrict-user-access/reviews/)

## Tags

 * [api](https://wordpress.org/support/topic-tag/api/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 3 replies
 * 2 participants
 * Last reply from: [ggarmory](https://wordpress.org/support/users/ggarmory/)
 * Last activity: [7 years, 9 months ago](https://wordpress.org/support/topic/shortcode-getting-rua_get_user_access/#post-10603337)
 * Status: resolved