View Categories

Flexible Printing – Filters

Filter for managing more than one printer

If you need to manage more than one printer, it would be necessary to paste the following filter in the functions.php file:

add_filter( 'flexible_printing_get_option_dpd_uk_default_printer', 'flexible_printing_default_printer' );
add_filter( 'flexible_printing_get_option_dpd_default_printer', 'flexible_printing_default_printer' );
/**
* @param string $value
*
* @return string
*/
function flexible_printing_default_printer( $value )
{
$user = wp_get_current_user();
if ($user->user_login === 'user1') {
$value = 'printer1';
}
if ($user->user_login === 'user1') {
$value = 'printer2';
}

return $value;
}

In this case it is necessary to change the ‘user1’ and ‘user2’ to the username which is assigned to the particular user and the ‘printer1’, ‘printer2’ to the id of the actual printer. If you would like to use for instance 5 printers for 5 users, it is necessary to add more lines with the ‘if’ statements.

Scroll to Top