Well i can do it with this code finally:
global $current_user, $post;
$post_id = $post->ID;
$user_id = $current_user->ID;
$mi_serie = get_post_meta($post_id,'serie',true);
$id_serie = wt_get_ID_by_page_name($mi_serie);
$user_likes = get_user_meta( $user_id, 'bp_liked_blogposts', true );
if($user_likes[$id_serie] !='') {
DO SOMETHING
}
What this code does is:
Make something if the user LIKE the NAME of the post that is in the value of the ‘serie’ meta_key. The meta_value of serie must be a Name of page or post.
The wt_get_ID_by_page_name($mi_serie); function is a custom function that it isn’t in wordpress. Retrieve the post/page ID with its Name.
Put this in your functions.php that it’s in your actual theme.
function wt_get_ID_by_page_name($page_name)
{
global $wpdb;
$page_name_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '".$page_name."'");
return $page_name_id;
}
If you only want to do something if the actual post is liked, for example to use it in single.php or page.php you can use this code:
global $current_user, $post;
$post_id = $post->ID;
$user_id = $current_user->ID;
$user_likes = get_user_meta( $user_id, 'bp_liked_blogposts', true );
if($user_likes[$post_id] !='') {
DO SOMETHING
}else{
DO IF DON'T LIKE
}