WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 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:

Description

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();
	print_r($all_args);
	exit;
}
add_action( 'set_user_role', 'twentyeleven_set_user_role');

is

Array
(
    [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)

comment:1 nacin2 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 )

comment:2 SergeyBiryukov2 years ago

See #19134 for the old role.

Note: See TracTickets for help on using tickets.