'WordPress the_content filter is not working on the Divi Child theme
I have following code to filter the content:
function shibbir_restrict_content( $content ) {
$current_user = get_current_user_id();
$trim_words = wp_trim_words( $content, 10 );
if( is_single() ){
if( current_user_can( 'manage_options' ) ) {
$content = $content;
} else {
if( rcp_user_has_active_membership( $current_user ) ) {
$content = $content;
} else {
$content = $trim_words;
$content .= ' Please subscribe to view the content';
}
}
return $content;
}
return $content;
}
add_filter( 'the_content', 'shibbir_restrict_content' );
When I add this to the child theme of Divi then the filter is not working. Is there anything I am doing wrong?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
