Title: embed code
Last modified: August 30, 2016

---

# embed code

 *  Resolved [onirgoc](https://wordpress.org/support/users/onirgoc/)
 * (@onirgoc)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/embed-code-5/)
 * Hello,
 * In some case AAM do not have any way to manage access to front end. I am using
   The Events calendar and I want to restrict by example acces to venue and maps
   only for certains categories of users.
 * A simple way Is to use :
 * > if ( is_user_logged_in() ) {}else{}
 *  but it’s not manage by AAM of course.
 * Is there any way to embed some AAM code into my templates to let AAM manege access
   to those specific parts ?
 * I can provide parts of the code I want to protect if it make the question more
   easy to answer.
 * Thanks !
 * [https://wordpress.org/plugins/advanced-access-manager/](https://wordpress.org/plugins/advanced-access-manager/)

Viewing 10 replies - 1 through 10 (of 10 total)

 *  [vasyl_m](https://wordpress.org/support/users/vasyl_m/)
 * (@vasyl_m)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/embed-code-5/#post-6814021)
 * Hi onirgoc,
 * Actually AAM has very extensive and flexible API. It was developed by developers
   for developers. In your case I’ll show you the easiest way to accomplish your
   task so let’s base your solution on WordPress capabilities (you can either utilize
   existing WordPress capabilities or create your own; both things can be easily
   done with AAM UI under the **Capabilities** tab).
 * So let’s assume that you have few users that belong to your custom role **Event
   Manager**. Event Manager role has custom capability **Manage Events** which means
   that any user that belongs to this role also has this capability.
 * Advanced Access Manager during the initialization creates a singleton object **
   AAM** that is visible by any other plugin or theme through your WordPress.
 * So in your code you can do something like this:
 *     ```
       if (AAM::getUser()->hasCapability('Manage Events')) {
          //show somethings on your frontend page
       } else {
         //well, show nothing or something different
       }
       ```
   
 * Hopefully this is understandable and helpful.
    Regards, Vasyl
 *  Thread Starter [onirgoc](https://wordpress.org/support/users/onirgoc/)
 * (@onirgoc)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/embed-code-5/#post-6814045)
 * Thanks!
 * it’s not Events Manager but The Events Calendar from Tribe…
 * but if I understand you I already find “Read Private Tribe Events”, “Read Private
   Tribe Venues”, “Read Private Tribe Organizers” in AAM UI under capabilities.
 * >  if (AAM::getUser()->hasCapability(Read Private Tribe Organizers’)) {
   >  //show
   > somethings on your frontend page } else { //well, show nothing or something
   > different }
 * and the same for “venues”
 * so am I in the right direction ?
    well after I have to find what to put under“
   show sometings”
 * For now this is what I was using; As you can see it’s really basic and do not
   allow to check that user is allowed to see “venue” and “map”
 * > <?php
   >  /** * Single Event Meta Template * * Override this template in your 
   > own theme by creating a file at: * [your-theme]/tribe-events/modules/meta.php**
   > [@package](https://wordpress.org/support/users/package/) TribeEventsCalendar*/
   > do_action( ‘tribe_events_single_meta_before’ );
   > // Check for skeleton mode (no outer wrappers per section)
   >  $not_skeleton =!
   > apply_filters( ‘tribe_events_single_event_the_meta_skeleton’, false, get_the_ID());
   > // Do we want to group venue meta separately?
   >  $set_venue_apart = apply_filters(‘
   > tribe_events_single_event_the_meta_group_venue’, false, get_the_ID() ); ?>
   > <?php if ( $not_skeleton ) : ?>
   >  <div class=”tribe-events-single-section tribe-
   > events-event-meta primary tribe-clearfix”> <?php endif; ?>
   >  <?php
   >  // Only for logged in user
   >  if ( is_user_logged_in() ) { do_action( ‘tribe_events_single_event_meta_primary_section_start’);
   >  // Always include the main event details in this first section
   >  tribe_get_template_part(‘
   > modules/meta/details’ );
   >  // If we have no map to embed and no need to keep the venue separate…
   >  if (!
   > $set_venue_apart && ! tribe_embed_google_map() ) { tribe_get_template_part(‘
   > modules/meta/venue’ ); } elseif ( ! $set_venue_apart && ! tribe_has_organizer()&&
   > tribe_embed_google_map() ) { // If we have no organizer, no need to separate
   > the venue but we have a map to embed… tribe_get_template_part( ‘modules/meta/
   > venue’ ); echo ‘<div class=”tribe-events-meta-group tribe-events-meta-group-
   > gmap”>’; tribe_get_template_part( ‘modules/meta/map’ ); echo ‘</div>’; } else{//
   > If the venue meta has not already been displayed then it will be printed separately
   > by default $set_venue_apart = true; }
   >  // Include organizer meta if appropriate
   >  if ( tribe_has_organizer() ) { tribe_get_template_part(‘
   > modules/meta/organizer’ ); }
   >  do_action( ‘tribe_events_single_event_meta_primary_section_end’ );
   >  ?>
   >  <?php if ( $not_skeleton ) : ?>
   >  </div> <?php endif; ?>
   >  <?php if ( $set_venue_apart ) : ?>
   >  <?php if ( $not_skeleton ) : ?> <div class
   > =”tribe-events-single-section tribe-events-event-meta secondary tribe-clearfix”
   > > <?php endif; ?> <?php do_action( ‘tribe_events_single_event_meta_secondary_section_start’);
   >  tribe_get_template_part( ‘modules/meta/venue’ );
   >  tribe_get_template_part(‘
   > modules/meta/map’ );
   >  do_action( ‘tribe_events_single_event_meta_secondary_section_end’ );
   >  ?> <?
   > php if ( $not_skeleton ) : ?> </div> <?php endif; ?> <?php endif; do_action(‘
   > tribe_events_single_meta_after’ ); } else {
   > }
 * Thanks for your help. Will let you know as soon as I have done tests.
 *  Thread Starter [onirgoc](https://wordpress.org/support/users/onirgoc/)
 * (@onirgoc)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/embed-code-5/#post-6814047)
 * But there is no capabilities for visitor ? How can I forbide access then ?
 * Thanks.
 *  Thread Starter [onirgoc](https://wordpress.org/support/users/onirgoc/)
 * (@onirgoc)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/embed-code-5/#post-6814051)
 * mmm…stupid question…visitor has no capabilities so no access… 😉
 *  [vasyl_m](https://wordpress.org/support/users/vasyl_m/)
 * (@vasyl_m)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/embed-code-5/#post-6814053)
 * Hi onirgoc,
 * I was using Event Manager role as an example. It does not refer to any plugin.
   But you are moving in right direction.
 * AAM is intelligent enough to recognize if user is logged in or not. That is why
   the code that I mentioned above will also work for Visitors.
 * You are absolutely right. Visitors do not have any capabilities or roles, that
   is why the condition with **hasCapability** will always return **false** for 
   Visitors.
 * Please also notice. List of capabilities in the current AAM version shows only
   human readable capability name. We already working on the next AAM release that
   shows also the internal capability id right next to the capability title. You
   can get the development version of our next release from the [GitHub](https://github.com/VasylTech/advanced-access-manager).
 * So in your case the capability “**Read Private Tribe Organizers**” internally
   may be stored as **read_private_tribe_organizers**. And _hasCapability_ works
   only with internal capability id.
 * Regards,
    Vasyl
 *  Thread Starter [onirgoc](https://wordpress.org/support/users/onirgoc/)
 * (@onirgoc)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/embed-code-5/#post-6814057)
 * need help !!!
 * I tryed this:
 * >  <?php
   >  /** * Single Event Meta Template * * Override this template in your
   > own theme by creating a file at: * [your-theme]/tribe-events/modules/meta.php**
   > [@package](https://wordpress.org/support/users/package/) TribeEventsCalendar*/
   > do_action( ‘tribe_events_single_meta_before’ );
   > // Check for skeleton mode (no outer wrappers per section)
   >  $not_skeleton =!
   > apply_filters( ‘tribe_events_single_event_the_meta_skeleton’, false, get_the_ID());
   > // Do we want to group venue meta separately?
   >  $set_venue_apart = apply_filters(‘
   > tribe_events_single_event_the_meta_group_venue’, false, get_the_ID() ); ?>
   > <?php if ( $not_skeleton ) : ?>
   >  <div class=”tribe-events-single-section tribe-
   > events-event-meta primary tribe-clearfix”> <?php endif; ?>
   >  <?php
   >  // Only for allowed user
   >  if (AAM::getUser()->hasCapability(‘Read Private 
   > Tribe Organizers’)) {
   >  do_action( ‘tribe_events_single_event_meta_primary_section_start’ );
   >  // Always include the main event details in this first section
   >  tribe_get_template_part(‘
   > modules/meta/details’ );
   >  // If we have no map to embed and no need to keep the venue separate…
   >  if (!
   > $set_venue_apart && ! tribe_embed_google_map() ) { tribe_get_template_part(‘
   > modules/meta/venue’ ); } elseif ( ! $set_venue_apart && ! tribe_has_organizer()&&
   > tribe_embed_google_map() ) { // If we have no organizer, no need to separate
   > the venue but we have a map to embed… tribe_get_template_part( ‘modules/meta/
   > venue’ ); echo ‘<div class=”tribe-events-meta-group tribe-events-meta-group-
   > gmap”>’; tribe_get_template_part( ‘modules/meta/map’ ); echo ‘</div>’; } else{//
   > If the venue meta has not already been displayed then it will be printed separately
   > by default $set_venue_apart = true; }
   >  // Include organizer meta if appropriate
   >  if ( tribe_has_organizer() ) {
   >  tribe_get_template_part( ‘modules/meta/organizer’);}
   >  do_action( ‘tribe_events_single_event_meta_primary_section_end’ );
   >  ?>
   >  <?php if ( $not_skeleton ) : ?>
   >  </div> <?php endif; ?>
   >  <?php if ( $set_venue_apart ) : ?>
   >  <?php if ( $not_skeleton ) : ?> <div class
   > =”tribe-events-single-section tribe-events-event-meta secondary tribe-clearfix”
   > > <?php endif; ?> <?php do_action( ‘tribe_events_single_event_meta_secondary_section_start’);
   >  tribe_get_template_part( ‘modules/meta/venue’ );
   >  tribe_get_template_part(‘
   > modules/meta/map’ );
   >  do_action( ‘tribe_events_single_event_meta_secondary_section_end’ );
   >  ?> <?
   > php if ( $not_skeleton ) : ?> </div> <?php endif; ?> <?php endif; do_action(‘
   > tribe_events_single_meta_after’ ); } else { //nothing }
 * Under admin user I get the page without details, venue, organizer and under guest
   user a white page…where am I wrong ?
 * Thanks if you can help !
 *  Thread Starter [onirgoc](https://wordpress.org/support/users/onirgoc/)
 * (@onirgoc)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/embed-code-5/#post-6814060)
 * OKKKK ! I got it…now only the visitor page is blank…probably I put the conditional
   to high…
 * Thanks this is really great help !
 * I will an other request in an other post about something you can add in futur
   to your great plugin. 🙂
 *  Thread Starter [onirgoc](https://wordpress.org/support/users/onirgoc/)
 * (@onirgoc)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/embed-code-5/#post-6814067)
 * Find this under guest user :
 * Fatal error: Call to undefined method stdClass::has_cap() in (hide exact adress
   for security ) \…\…\…\….\wp-content\plugins\advanced-access-manager\Application\
   Core\Subject.php on line 215
 * any idea ?
 *  [vasyl_m](https://wordpress.org/support/users/vasyl_m/)
 * (@vasyl_m)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/embed-code-5/#post-6814083)
 * Nice catch **onirgoc**!
 * Fix can be found in our development version on the [github](https://github.com/VasylTech/advanced-access-manager)
 * Keep me updated!
    Regards, Vasyl
 *  Thread Starter [onirgoc](https://wordpress.org/support/users/onirgoc/)
 * (@onirgoc)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/embed-code-5/#post-6814100)
 * GREAT !!!
    WORKING !!!
 * …then just buy the pro version ! Thanks for great support and great plugin !

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘embed code’ is closed to new replies.

 * ![](https://ps.w.org/advanced-access-manager/assets/icon-256x256.png?rev=3447421)
 * [Advanced Access Manager – Access Governance for WordPress](https://wordpress.org/plugins/advanced-access-manager/)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-access-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-access-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-access-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-access-manager/reviews/)

 * 10 replies
 * 2 participants
 * Last reply from: [onirgoc](https://wordpress.org/support/users/onirgoc/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/embed-code-5/#post-6814100)
 * Status: resolved