Hide Private Content From Non Users With PHP Code Snippet

Hide private content from non users with PHP Code snippet, You can restrict non members to see any of your private content. This short code allows you to write a private content in a post.

Usage:

[html][mem] ..content.. [/mem][/html]

Add This code in your functions.php
[php]
function member( $atts, $content = null ) {
if ( is_user_logged_in() && !is_null( $content ) && !is_feed() ) {
return $content;
return ”;
} else {

$yonlendir = get_permalink();
$form = wp_login_form(array(‘echo’ => false, ‘redirect’ => $yonlendir ));
return $form;
}
}
add_shortcode( ‘mem’, ‘member’ );
[/php]

0 Likes
Riz
Riz

Passion is beyond limitation. If you’re passionate about ANYTHING, nobody can stop you not to do what you want. Blogging and Web Designing is my passion that don’t drive me to do what I want but push me as well to share fanatical stuff with people.

There is 1 comment
  1. Sam A

    It is definitely uses to hide some code which are not user of your programming. It helps you to make some privacy which you like to not show to ordinary member. This is the way to make it possible.

Your email address will not be published. Required fields are marked *

div#stuning-header .dfd-stuning-header-bg-container {background-image: url(http://www.downgraf.com/wp-content/uploads/2017/04/login-back.jpg);background-size: cover;background-position: center center;background-attachment: scroll;background-repeat: no-repeat;}#stuning-header div.page-title-inner {min-height: 500px;}