[wp-hackers] Like Posts - Store Data in DB, User_Meta or Post_Meta
BenderisGreat
greglancaster71 at gmail.com
Mon Nov 11 23:33:19 UTC 2013
Would this be the fastest way to check the database?
function alreadyLikedCheck() {
global $wpdb, $post, $current_user;
get_currentuserinfo();
$user_id = $current_user->ID;
$post_id = $post->ID;
$checkLikeTable = $wpdb->get_row( $wpdb->prepare('SELECT * FROM ' .
$wpdb->prefix . 'ams_post_likes' .' WHERE user_id = %d AND post_id = %d',
$user_id, $post_id ));
if (isset($checkLikeTable)) {
echo "You Like This Post";
} else
{ echo "<button type='button' id='post_like' data-id='".get_the_ID()."'
data-nonce='".wp_create_nonce('like_button')."'
data-user='".get_current_user_id()."' class='btn btn-success'>Like This
Post</button>"; }
}
--
View this message in context: http://wordpress-hackers.1065353.n5.nabble.com/Like-Posts-Store-Data-in-DB-User-Meta-or-Post-Meta-tp42769p42796.html
Sent from the Wordpress Hackers mailing list archive at Nabble.com.
More information about the wp-hackers
mailing list