wordpress - php parameters passed inside function is not working -


in php/wordpress have made function. want pass parameteres inside function show result according that. far function code this

$user_id = get_current_user_id(); function check_user_access($role, $action = null ) {     if( $role == 'subscriber') {         if( $action = 'check_customer' ) {             $check_customer = $wpdb->get_var("select count(id) `table1` `user_id` = $user_id");             return $check_customer;         }          if( $action = 'check_users' ) {             $check_users = $wpdb->get_var("select count(id) `table2` `user_id` = $user_id");             return $check_users;         }     } } 

now using function this

$role = 'subscriber'; $check_customers = check_user_access($role, $action = 'check_users' ); if( $check_users <=1 ) {     //do something; } if( $check_users > 1 ) {     //do other; } 

but showing result of $action = 'check_customer'. means working first block condition. can tell me how solve this? doing wrong?

change

 if( $action = 'check_customer' ) {} 

to

if( $action == 'check_customer' ) {} 

= means assignment operator

== means comparison operator

refer - from here


Comments