Skip to content

Instantly share code, notes, and snippets.

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 OscarAbadFolgueira/5c335ffb27e4a5603ade to your computer and use it in GitHub Desktop.
Save OscarAbadFolgueira/5c335ffb27e4a5603ade to your computer and use it in GitHub Desktop.
creates a [restrict_pcs] that you can use to restrict some contents of your posts or pages
<?php
/*
Plugin Name: OAF Restrict Partial Content Shortcode
Plugin URI: https://www.oscarabadfolgueira.com
Description: This plugin creates a [restrict_pcs] that you can use to restrict some contents of your posts or pages.
Version: 1.0
Author: Oscar Abad Folgueira
Author URI: https://www.oscarabadfolgueira.com
License: GPLv2 only
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
function oaf_restrict_partial_content_shortcode( $atts, $content = null ) {
if ( is_user_logged_in() && !is_null( $content ) && !is_feed() ) {
return $content;
} else {
return __( 'Upps! Este contenido sólo está disponible para usuarios registrados.', 'oaf_rpcs' );
}
}
add_shortcode ('restrict_pcs', 'oaf_restrict_partial_content_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment