Skip to content

Instantly share code, notes, and snippets.

@MjHead
Created November 20, 2020 09:23
Show Gist options
  • Save MjHead/c68c01f2f6cd2a50aadea13e492b26b2 to your computer and use it in GitHub Desktop.
Save MjHead/c68c01f2f6cd2a50aadea13e492b26b2 to your computer and use it in GitHub Desktop.
<?php
add_action( 'edit_user_profile', 'my_user_likes' );
add_action( 'show_user_profile', 'my_user_likes' );
function my_user_likes( $user ) {
// user-meta-store you need to replace with your actual Data Store slug
$liked = get_user_meta( $user->ID, 'je_data_store_user-meta-store', true );
echo '<h2>User Likes</h2>';
if ( ! $liked ) {
echo 'No likes';
} else {
foreach ( $liked as $post_id ) {
printf( '<a href="%1$s">%2$s</a><br>', get_permalink( $post_id ), get_the_title( $post_id ) );
}
echo '<br><br>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment