Email notification with every new article in a wordpress site - wordpress

i was looking for a way to include some plugin or something like that in my wordpress site. This "plugin" send a mail (to specific contacts) every time i create a new content in my website (event, article, etc..). do you guys know a way to do that? Thanks a lot!

Recommend to solve this with the publish post action hook - mail to all recipients will be sent on publishing a post. This is how you can achieve it:
add_action('publish_post','notify_my_buddies');
function notify_my_buddies($ID, $post ) {
$recipients = get_option('my_recipients');
foreach($recipients as $rec) {
wp_mail($rec,"New Post: ".$post->post_title, "Any content pass here ...");
}
}

Related

Send thank you email in wordpress after user is redirected from other website

This is the problem I am trying to find a solution to: I manage a wordpress site that deals with donations. There are 5 options. Once the user clicks on one of them they are sent to a third party site to make a donation. After they make the donation they are redirected back to my site with a set of data (name, email etc.). What I need to do is get that data and send a thank you email to the user. Is there some wordpress plugin I can use to handle the incoming data and send the email? Or maybe use a plugin like Contact form 7 to do it? I am not really familliar with wordpress. Really basic knowledge
The easiest way to do this would be to create a custom page template with logic to capture the data sent after donating in it and apply the template to a page.
E.g.
wp-content/themes/your-theme/ipn.php
<?php
/**
* Template Name: IPN
*/
// Grab the data that's returned, however it's returned.
$data = $_GET['data'];
// Use WordPress mail function to send your email
wp_mail( $to, $subject, $message, $headers, $attachments );
// Either redirect to another page or display a thank you message.
Then go into your admin, create a new page called IPN, select your page template from the drop down and publish. You can use the URL to this page to pass data back to it from the 3rd party site after payment.

WordPress: Stop spam posts programmatically

I have an image sharing site built on WordPress and recently I've had a lot of bots registering a user and creating a spam post with links to various sites.
After installing WP-reCAPTCHA the numbers have reduced but there are still 'attacks' every hour or so.
I'm trying to handle this programmatically now, by hooking into wp_insert_post_data (which is called whenever a post/revision is saved). I inspect the post data and if it contains a link I remove the post's content and set the status to draft so that it isn't published.
But it's still a nuisance to delete spam users and posts from the back end.
Is there a better hook I can use to stop the saving of the post even happening? i.e. can I reject the call to save the post?
Here is the code I'm currently using:
function block_spam_posts($data, $postarr) {
// if the post contains a link, set it to draft status
$post_content = $data['post_content'];
if (strpos($post_content,'http') !== false) {
$data['post_content'] = 'Post data removed by anti-spam measures.';
$data['post_status'] = 'draft';
}
}
add_filter('wp_insert_post_data', 'block_spam_posts',1,2);
Thanks for your help.
I found the answer here:
https://wordpress.stackexchange.com/questions/82354/how-can-i-hook-into-creating-a-new-post-and-execute-wp-die-before-the-post-is
I'm using the right hook. All I need to do is call wp_die() once the criteria for a spam post has been met.
Hope this helps others.

wordpress profile builder not redirecting properly after registration

I am using "profile builder pro" plugin of wordpress in wordpress website and it works well except for "redirection after successfull registration" as it is redirecting to the same page.
here is a live link of it
http://www.selfmadesounds.com/dev3/register
Login redirection and register redirection i have set from backend and it is working for login but not for registration.
Any help will be pretty much accepted.
I dont have the pro version but had the same problem, i fixed it by hardcoding the redirect link.
Go to the page "wp-content/plugins/profile-builder/front-end/wppb.register.php"
Move to line 1026 and add the following:
$redirectLink = 'http://www.yourdomain.com/REDIRECT-PAGE';
Just simply overwrite the redirectLink before it go's and redirect.
Hope it helps
Please don't edit plugin files directly! Really bad practice.
You can solve this in a couple of ways, one way is to check if logged in and on a specific page then redirect to another page. There are nicer ways then hardcoding the urls and id, but this is better then editing plugin files directly.
Put this in your functions.php, change url and id to the one you need:
function isLoginPage() {
global $post;
return is_object($post) && (int) $post->ID === 1;
}
add_action('wp', 'redirectFromLoginpage');
function redirectFromLoginpage() {
if (isLoginPage()) {
global $wppb_login;
if (is_user_logged_in() || isset($wppb_login->ID)) { // Already logged in
wp_redirect(site_url() . '/redirect-to-this-url/');
die;
}
}
}

Wordpress post into Jquery mobile framework

I want to show my wordpress post into jquery mobile application... But so far i didnt got the success. I am using jquery.post() function but my response comes empty....
Request to the desired url goes well , status comes 200 ok but response coming is always blank :( Although the same post function & url is working fine in other php pages....
below is my code
function get_Time(cityCode,date){
jQuery.post(
"http://test.local/time/",
{ city: cityCode, date:date},
function (data){jQuery('#print_time').html(data);}
);
}
function _get_Time(response)
{
alert("response:"+response);
var time = new Array();
time = response.split('|')
jQuery("#print_time").html(time[0]);
}
Please give me some solution for showing my wordpress post (only text + links) content into my jquery mobile applicaton....
I am not sure about what you are going to do. It seems to me, like you want to retrieve a certain WordPress post content + additional information via Ajax, I think the easiest way to do it is the following:
Write a custom server-side PHP-Script (which possibly takes a WordPress Slug or ID)
Create a connection to the database in this script, get the post contents you want to have and return these as text or JSON to your JQuery mobile and use it
It might work in a way like this (not tested):
include ‘path-to-wp-directory/wp-blog-header.php’;
$post_id=0;
if(isset($_REQUEST['post_id'])) {
$post_id=intval($_REQUEST['post_id']);
}
global $wpdb;
$post_content = $wpdb->get_var("SELECT post_content FROM $wpdb->posts WHERE post_id=".$post_id." AND post_status='publish'";
echo $post_content;
This is only possible if you have access to the server, of course. If you want to get Post Content from an external WordPress Blog, then you should consider using the RSS Feed.
The following article shows how to load WordPress functions in an external PHP Script, which also might be useful: http://www.bloggingtips.com/2009/01/25/use-wordpress-functions-externally/

Single page login screen for all password protected Wordpress pages

I have a setup of Wordpress blog with a couple of password-protected pages, each of them with special content and a different password.
I would like to have a login form (password-only) on a single public Wordpress page, which redirects to the corresponding password-protected page, according to the submitted password.
Anybody know of a good free plugin for that or any ideas how to fetch Wordpress pages by password?
I found a solution:
$result = $wpdb->get_results("SELECT ID FROM wp_posts WHERE post_password = '{$_POST['post_password']}'");
if($result) {
wp_safe_redirect(get_bloginfo('url') . "/?page_id=" . $result[0]->ID);
} else {
wp_safe_redirect(wp_get_referer());
}
Do you think it is reliable enough?
How can this functionality be implemented in such a way, that it preserve itself upon Wordpress update?
Thanks!

Resources