Undefined notice on unset field

The error is that you’re trying to read $value[‘kk_youtube’] when there is no kk_youtube key in the array (undefined index). Rather than use isset, use get_post_meta with the third argument “single” true: $youtube_link = esc_attr( get_post_meta( $post->ID, ‘kk_youtube’, true ) ); This is effectively the same as doing: $value = get_post_custom( $post->ID ); if ( … Read more

Hook into install email

If you see the code, there is no hook to do that. But you can create your own function and remove the part that you don’t need like this function custom_wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = ”, $user_password = ”, $language=”” ) { if ( !empty( $deprecated ) ) _deprecated_argument( __FUNCTION__, ‘2.6’ ); wp_check_mysql_version(); … Read more

Rewriting URLs with a query string

First of all, you have to make sure to register your public query vars with WordPress so it recognizes your rewrite rule vars. Add this code on your functions.php file: add_rewrite_rule(‘^(tips)/([^/]*)/([^/]*)/?’, ‘index.php?name=$matches[1]&id=$matches[2]&filter_id=$matches[3]’,’top’); add_filter(‘query_vars’, ‘foo_my_query_vars’); function foo_my_query_vars($vars){ $vars[] = ‘id’; $vars[] = ‘filter_id’; return $vars; } After that, enter on your Permalinks Settings page to flush … Read more

How to add conent (text) to Add New pages form of admin in WordPress

The hook to use here is admin_notices. However in register_activation_hook and register_deactivation_hook it shouldn’t be used because these function run when plugin activates and deactivates instance. A workaround it we use add_option when plugin activates and delete_option when plugin deactivates. Here is the code. Hopefully you will understand it properly <?php function my_admin_notice() { $screen … Read more

how to create table during plugin installation in side a class

You should run your register_activation_hook after creating object. class Notification { function jal_install() { global $wpdb; global $jal_db_version; $table_name = $wpdb->prefix . ‘fnotice’; $charset_collate = $wpdb->get_charset_collate(); $sql = “CREATE TABLE $table_name ( id INT NOT NULL AUTO_INCREMENT, msg varchar(500) NOT NULL, time DATETIME NOT NULL, type varchar(350) NOT NULL, link varchar(350) NOT NULL, status ENUM(‘0’, … Read more

How should I use wpdb class to submit a form in admin dashboard?

If you don’t want to use the Dashboard Widgets API you can use this code snippet that I have quickly concocted as a starting point: function dashboard_daily_post_metabox() { add_meta_box( ‘wt_id’, ‘Daily Post’, ‘dashboard_daily_post_process’, ‘dashboard’, ‘normal’, ‘high’ ); } add_action( ‘wp_dashboard_setup’, ‘dashboard_daily_post_metabox’ ); function dashboard_daily_post_process() { global $wpdb; ?> <form method=”post”> <label>Age <input type=”text” name=”wt_age” value=”<?php … Read more

Get Commentor IP When Marking Comment As Spam

You are missing 2 parameters in your function report_spam. Also the priority should not be 1. Try the code below. add_action(‘transition_comment_status’, ‘report_spam’, 10, 3); function report_spam($new_status, $old_status, $comment){ if($new_status == ‘spam’){ var_dump($comment->comment_author_IP); die; } } I’ve set die so that you can check and manipulate what you want.