Hi Shamim, I have this function on my function.php page (you wrote it and it works perfectly).
add_filter( 'fep_filter_message_before_send', function( $message ) {
// The @ symbol must be surrounded by character on both sides
$message['message_content'] = preg_replace( '/[^@\s]*@[^@\s]*\.[^@\s]*/', '[EMAILNASCOSTA]', $message['message_content'] ); # for emails
// Take any string that contains only numbers, spaces and dashes,
// Can optionally have a + before it.
$message['message_content'] = preg_replace( '/\+?[0-9\-]{5,}/', '[TELEFONONASCOSTO]', $message['message_content'] ); # for phone numbers
return $message;
});
Now I would like to make sure that the function occurs and is only activated if a user has a value entered in a specific metakey other than “no” in the profile.
I wrote this feature and it works:
$user = get_current_user_id();
$privacytel = get_user_meta( $user, 'privacytel', true );
if ( is_user_logged_in() ) {
if ( $privacytel != 'No') {
YOUR FUNCTION SHOULD BE STARTED HERE, WHEN THE TWO "IF" ARE VERIFIED, WHEN THE USER IS LOGGED-IN AND WHEN THE METAKEY $PRIVACYTEL IN HIS PROFILE HAS AN EMPTY OR DIFFERENT VALUE FROM NO.
}
How can I add it to your function to get my goal I wrote above?
I hope I was clear.
Thanks.