Skip to content

Instantly share code, notes, and snippets.

@1naveengiri
Last active March 15, 2017 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1naveengiri/afc4400d88c795e82322f9ea061759cd to your computer and use it in GitHub Desktop.
Save 1naveengiri/afc4400d88c795e82322f9ea061759cd to your computer and use it in GitHub Desktop.
Hooked code to disable like feature for user on its own media.
<?php
add_action('init','rtmedia_disable_media_like_init');
/**
* Function to extend like disable check functionality.
*/
function rtmedia_disable_media_like_init(){
if( function_exists( 'rtmedia_disable_own_media_like' ) ) {
add_filter( 'rtmedia_check_enable_disable_like','rtmedia_disable_own_media_like' , 10, 1 );
}
}
/**
* Function to add check for user media so that we could disable like feature for user on its own media.
* @param boolean $enable_like value whether to enable like feature or not extended code form rtmedia_check_enable_disable_like action.
* @return boolean value whether to enable like.
*/
function rtmedia_disable_own_media_like( $enable_like ) {
global $rtmedia;
$options = $rtmedia->options;
$model = new RTMediaModel();
$media = $model->get_media( array(
'id' => rtmedia_id(),
), 0, 1 );
$author = (isset($media[0]->media_author) )? intval($media[0]->media_author) : 0;
$current_user_id = get_current_user_id();
if (( ( isset( $options['general_enableLikes'] ) && '1' == $options['general_enableLikes'] ) || ! isset( $options['general_enableLikes'] ) ) && $author !== $current_user_id ) {
return true;
} else {
return false;
}
return false;
}
@pranali333
Copy link

Add this code in functions.php file of your theme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment