This is a test Site

Howto: Restricted custom field access with Pods

Example: Display the description of  videos for everyone, but optionally restrict the acces to the video.

1. define in the Pod videoliste a video custom field (video) and a YEs/NO custom field (free).

2. define a template to list the videos: videotempl (Using Shortcodes in Pods Templates)

<table class="stripetabelle">
	[if free]

3. Insert in functions.php the restricted_video function:

function restricted_video($videourl){
	if ( is_user_logged_in() ) {
	   $videobefehl = '<video class="wp-video-shortcode" type="video/mp4" controls="controls"  preload="metadata" style="max-width:100%;" src="'. $videourl . '">Ihr Browser kann dieses Video nicht wiedergeben.</video>';
	 return $videobefehl;
	} else {
	 return "Nur Sichtbar für eingeloggte Benutzer";
add_action('init', 'user_eingelogt');

4. Insert in a page the following shortcode:

Pods embed error: Pod not found

5. To avoid that the video is displayed at the front, acivate the “Auto Templates Options” as follows:

Single item view templateName -> videotemplate Single Template Location -> replace

An alternative to the function restricted_video is to use “is_logged_in” shortcodes from  another plugin or function (see for example https://firstsiteguide.com/show-part-content-logged-users-guests/)