Statements making use of user-defined functions are not safe for replication.
For an example, see
sql/udf_example.cc in the source tree. For a collection of existing UDFs see http://www.mysqludf.org/.
There are alternative ways to add a new function: writing a native function (which requires modifying and compiling the server source code), or writing a stored function.
Creating User-defined FunctionsHow to create user-defined functions in C/C++
CREATE FUNCTION UDFCreate a user-defined function
DROP FUNCTION UDFDrop a user-defined function
mysql.func TableUser-defined function information
User-defined Functions SecurityMariaDB imposes a number of limitations on user-defined functions for security purposes