Untitled
unknown
plain_text
8 months ago
947 B
5
Indexable
add_filter('option_salesking_all_agents_shop_all_customers_setting', function($val){
$user_id = get_current_user_id();
if (isset($_COOKIE['salesking_switch_cookie'])){
$switch_to = sanitize_text_field($_COOKIE['salesking_switch_cookie']);
if (!empty($switch_to) && is_user_logged_in()){
$udata = get_userdata( get_current_user_id() );
$name = $udata->first_name.' '.$udata->last_name;
$agent = explode('_',$switch_to);
$customer_id = intval($agent[0]);
$agent_id = intval($agent[1]);
$agent_registration = $agent[2];
$udataagent = get_userdata( $agent_id );
$registered_date = $udataagent->user_registered;
if ($user_id === $customer_id && $agent_registration === $registered_date){
$user_id = $agent_id;
}
}
}
if ($user_id == 1234){ // replace 1234 with the ID of your agent with full permissions
$val = 1;
}
return $val;
}, 10, 1);Editor is loading...
Leave a Comment