wp_mail doesn’t work when logged in?

You’ve got a typo in the hook that runs for logged in users: add_action(‘wp_ajax_search_notify_emaill’, ‘search_notify_email’); There’s an extra l in the hook name. The hook names need to be the same, apart from nopriv_, so you should have: add_action(‘wp_ajax_nopriv_search_notify_email’, ‘search_notify_email’); add_action(‘wp_ajax_search_notify_email’, ‘search_notify_email’); When you send an AJAX request with an action WordPress runs the hook … Read more

add_action( ‘publish_pelicula’, ‘post_published_notification’, 10, 2 ); does not trigger propperly

Well let’s compare the hook to one that is working: add_action( ‘admin_init’, array( $this, ‘page_init’ ) ); add_action( ‘publish_pelicula’, ‘post_published_notification’, 10, 2 ); page_init() and post_published_notification() are both methods of the MySettingsPage class, but you’ve set the action callbacks for each of them differently. The second argument for add_action() is a callback. It tells WordPress/PHP … Read more

Pass Variables or Variable Place-Holder from Editor to PHP

You should use str_replace, which accepts arrays as arguments: $content = “Email: {{email}}\nFirst Name: {{first_name}}”; $body = str_replace( [‘{{email}}’, ‘{{first_name}}’], [‘[email protected]’, ‘Mickey Mouse’], $content ); Be careful about using $ in your placeholders. Since it’s widely used in PHP, it’s not safe. It was the reason I’ve used mustache-like syntax in my example.

WordPress email could not be sent

The most common reason for this is that your WordPress hosting server is not configured to use PHP mail() function. How to configure your mail with wordpress and here is smtp plugin link

wp-mail attachment is not sent for no reason?

I changed the code to this and it worked ! Don’t know why I should do this and this is very odd but whatever. function send_mail_to_admin($orderId , $attachment_img){ $attachment_img = str_replace(“https://seabou.com/wp-content” , “” , $attachment_img); $attachment_img = array( WP_CONTENT_DIR . $attachment_img ); $headers = array(‘Content-Type: text/html; charset=UTF-8′,’From: انجمن آبزیان <[email protected]>’); $body = “<html><body> <b style=”font-size:14px;direction:rtl;text-align:center;”>یک … Read more

How to disable wp_mail for all users except for admins?

You could use the email address to get the user object, which will include the user ID. You can use the user ID to check the user’s capabilities to see if they have a capability assigned to the admin user role, and if not, unset the address: add_filter(‘wp_mail’,’disabling_emails’); function disabling_emails( $args ){ $user = get_user_by( … Read more

wp_mail – using a custom field value for $to

I’m going to assume the folks receiving these emails has gone through the whole two step opt in procedure or they have given their consent in some other way. There is an action called {$status}_{$post_type} that fires whenever a post is transitioned from one status to another. So when a post is published, the hook … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)