WordPress.org

Forums

User Role Editor
[resolved] Get capabilities from "Other role" on saving profile (2 posts)

  1. RobinWebber
    Member
    Posted 1 year ago #

    Hi there,

    I'm trying to figure out how I can get the capabilities from the "Other roles" within the 'profile_update' action. I tried with user_can($user->ID, 'custom_capability'), but it doesn't receive the capabilities from the "Other roles" in this way. When I add to capability to the primary role, it does work.

    Could you tell me how I can detect all the capabilities together from the primary and other roles like this?

    Thank you!

    https://wordpress.org/plugins/user-role-editor/

  2. Vladimir Garagulya
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    Look at wp-includes/capabilities.php WP_User object structure.
    Properties $user->allcaps and $user->roles should help you.

    /**
    	 * All capabilities the user has, including individual and role based.
    	 *
    	 * @since 2.0.0
    	 * @access public
    	 * @var array
    	 */
    	var $allcaps = array();

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • User Role Editor
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.