See if the email exists or not

First, you need to create the following function: function checkEmailAlreadyExists( $message_id ) { $posts_with_meta = get_posts( array( ‘posts_per_page’ => 1, // we only want to check if any exists, so don’t need to get all of them ‘post_type’ => ‘my-custom-post-type’, ‘meta_key’ => ‘ticket_id’, ‘meta_value’ => $message_id, ‘fields’ => ‘ids’, // we don’t need it’s content, … Read more

How to let a user create a post by submitting a POST form?

The echo part should be at the end of your code. Keep that in mind, any echo or print should be at the end of your piece of code. <?php if( $_POST[‘title_given’] ) { // Create post object $my_post = array( ‘post_title’ => wp_strip_all_tags( $_POST[‘title_given’] ), ‘post_content’ => ‘Did it work??’, ‘post_status’ => ‘publish’, ‘post_author’ … Read more

How to check if `comment_meta` exists before inserting the comment?

First off, you need to fix the comment_meta value. It should be an array of meta key and value pairs, and not just the meta value. So give the meta a key (or name), e.g. message_id, and then do something like so: ‘comment_meta’ => array( ‘message_id’ => preg_replace(‘~[<]~’,”,strstr($mail[‘header’]->message_id, ‘@’,true)), ), Now to check if a … Read more

“transition_post_status” action creating two post with wp_insert_post

I remember having a similar issue in a passed and checking if someone published custom post type first was solving the issue for me, something like this: add_action( ‘transition_post_status’, ‘post_create_on_publish_only’, 10, 3 ); function post_create_on_publish_only( $new_status, $old_status, $post ) { if ( ( $new_status == ‘publish’ ) && ( $old_status != ‘publish’ ) && ( … Read more

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