trying to find the comment hook I need for wordpress? - wordpress

I'm writing a wordpress plugin that will execute a certain function when a user submits a comment. The only issue is I'm using the hook "comment_post" which works but if that comment gets stopped by akismet I'm still logging that comment but now my numbers are off from what's on the actual site. Is there a comment_approved type hook I should be using instead?

this is something I was looking at not too long ago,
Only thing is the admin has to approve/edit the comment before the function would run..
using the wordpress admin hook:
wp_set_comment_status()
This function is run after changing the status of the comment by the admin..,
this looks for the status from 4 options
status ("delete", "approve", "spam", "hold").
You can check for the status approve?
do your caculation from there?

Related

Check condition before changing post status in wordpress

I have a form in the front end which enables users to submit posts. These posts are by default saved as pending. It can only set to publish by the admin. Before publishing certain conditions are to be checked before its set as published.
If the condition is true set post status as publish. If not set it as pending. What is the appropriate action hook to achieve this?
look here, there is 6 hooks than you can use for that :
https://core.trac.wordpress.org/browser/tags/5.3/src/wp-includes/post.php#L4058
just take care that the values that you use in your condition can also be change on this hooks then you have to test where you have the values you need.

PHP - action hook 'ninja_forms_daily_action'

I am looking at the source code for Ninja forms plugin. There is an action hook scheduled to execute daily in the file activation.php(line:51), but I cannot find the implementation of the action itself. I am assuming there should be a function called ninja_forms_daily_action somewhere in the code, but I can't seem to find it.
Am I missing something?
There is no associated function. The full code is the following:
wp_schedule_event( time(), 'daily', 'ninja_forms_daily_action' );
What this essentially translates to is:
Schedule a hook called ninja_forms_daily_action to be executed by the WordPress actions core on a daily interval, starting now.
This has been added so that developers can hook into it with their own functions...but the Ninja Forms core doesn't make use of it.
Read more about wp_schedule_event() in the docs.

How to set the filter for wordpress xmlrpc wp.getPosts while using node.js? (NOT PHP)

I was wondering how to set the filter option for wp.getPosts. I want to get posts with a status of 'trash'. is currently blank, and returns all posts other than trash.
I am using the xml-rpc wordpress api.
Here is my current code:
wpw.getPosts('<filter>', ['title','status'], function(err, data){
});
I am not sure what to put in the filter section, all the examples I could find are PHP examples and do not work in this context.
Is it even possible to get the posts with a status of 'trash'?
It is possible to get posts filtered by status. For the filter I added:
{status:'trash'}
This worked well. To get multiple status filters I just used an array:
{status: ['trash','publish']}

Contact form 7 will not email form due to it thinks its SPAM

I have a client that has upgraded wordpress to 3.7.1. Contact Form 7 now reports all forms as SPAM. I have WP-Mail installed and all was working before. Any ideas on how to fix this. Does anyone know where in the plugin code the form is getting marked as spam
Thanks
Thanks. I used this to amend this.
// a) Did not work for me.
add_filter('wpcf7_spam', '__return_false');
// b) There is another filter for the boolean used in the control statement.
add_filter('wpcf7_skip_spam_check', '__return_true');
Though the Contact Form 7 plugin successfully sends millions of emails every day, there are a host of issues that can stop or delay emails on both the sending and receiving ends. It depends entirely on your local Server & WordPress configuration.
You will need to investigate this issue for your particular local configuration. See Contact Form 7 Email Issues.
I think this issue happens when we use 3rd party service like sparkpost for sending email or something like that. I tried to check code base how cf7 check spam and found contact-form-7\includes
then submission.php file, check the code near or search with keyword "spam()"
elseif ( $this->spam() ) { // Spam!
$this->status = 'spam';
$this->response = $contact_form->message( 'spam' );
}
I think besides the wordpress core blacklist checking it also check the sender domain name and bla bla and mark any valid form submission as spam. So I made the spam checking commented.
This is not a permanent solution but it will help for now.
I was having the same problem this month and I managed to figure it out.
The default CONFIG -> DISCUSSION is applying the disallowed words list to the CF7 forms.
Try adding this code snippet to your theme functions.php file:
/**
* CONTACT FORM 7
* Disable WP Disallowed List for SPAM validation
*/
add_filter( 'wpcf7_submission_has_disallowed_words', '__return_false', 10, 2 );
It worked for me.

Is it possible to create categories that are available in a Wordpress theme by default?

Is there a way of having categories available right after installing a theme.
For instance, if a theme post content to a loop which retrieves posts with the category "Tagline". Is there a way of having the category "Tagline" by default (in the theme)?
(So the end user wouldn't have to create it himself/herself)
Try using wp_insert_category(); -- see: http://codex.wordpress.org/Function_Reference/wp_insert_category
You'd probably have to write an init function in functions.php that runs the first time the theme is activated and calls the above function. You'll want to write some error handling that prevents it from being run multiple times, however.

Resources