Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#20741 closed defect (bug) (invalid)

set_user_role action second argument not being passed

Reported by: hamidnazari Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.3.2
Component: Role/Capability Keywords:
Focuses: Cc:


According to capabilities.php:608

do_action( 'set_user_role', $this->ID, $role );

But the output of this when you change user's role

function twentyeleven_set_user_role($user_id, $role) {
	global $wpdb;
	$all_args = func_get_args();
add_action( 'set_user_role', 'twentyeleven_set_user_role');


    [0] => 2

where 2 is the user id.

Also: I wish I could receive both new and old roles in the action. Possible?

Change History (2)

#1 @nacin
6 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Receiving the old role is a duplicate of another ticket.

You are only getting one argument because add_action() defaults to one argument.

add_action( $tag, $function_to_add, $priority = 10, $accepted_args = 1 )

#2 @SergeyBiryukov
6 years ago

See #19134 for the old role.

Note: See TracTickets for help on using tickets.