Pull GET parameter from URL in functions.php

Contact Form 7 provides a recipe for Validation as a Filter which looks very much like what you are trying to do. Adapting their example to your code, I believe the following should work for you: add_filter( ‘wpcf7_validate_text*’, ‘custom_password_reset_validation_filter’, 10, 2 ); function custom_password_reset_validation_filter( $result, $tag ) { if (‘token’==$tag->name){ $token = isset($_POST[‘token’]) ? $_POST[‘token’] … Read more

WPDB function not saving

It could also be the result of this known bug: https://core.trac.wordpress.org/ticket/32315 If your data is larger than the varchar field length then $wpdb->insert will fail and produce no errors. If you don’t mind data being truncated if it’s larger than the field length, switch to $wpdb->query($wpdb->prepare(..)). Because of this stupid bug I haven’t used insert … Read more

Global variables and re-use

In general programming, globals are bad practice: You can’t easily look at the use of a global in one place and see all the other uses, e.g. where it was set or will be read later. You have many places to change the use of that variable if e.g. the use or format of it … Read more

Notify Author of the post if admin deletes his post and perform some function

Firstly, it’s better to user WP functions than write your own SQL. Even though it might be a bit more expensive: $post = get_post($post_ID); $authorid = $post->post_author; Secondly, it’s not get_usermeta(), but get_user_meta() and the complete call should include true as the third parameter: $currentPointNumber = get_user_meta($authorid, ‘points’, true); And then it’s update_user_meta(), again, and … Read more

Function to get content by ID

Instead of using get_posts, which you would use if you wanted to retrieve multiple posts in a loop, you should use get_post, which only retrieves one post by an ID. There is also a built-in excerpt so you might want to go with retrieving post_excerpt. function get_the_excerpt_id($post_id) { $find = get_post($post_id); $excerpt = $find->post_excerpt; $excerpt … Read more