Skip to content

Commit

Permalink
Use edit capability to check for permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
psrpinto committed Apr 18, 2024
1 parent d7db98d commit 4c8de23
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions templates/event.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,18 @@
<span class="first-time-contributor-tada" title="<?php esc_html_e( 'New Translation Contributor', 'gp-translation-events' ); ?>"></span>
<?php endif; ?>
<?php
if ( ! $event->end()->is_in_the_past() ) :
if ( ( $attendee instanceof Attendee && $attendee->is_host() ) || current_user_can( 'manage_options' ) || $user->ID === $event->author_id() ) :
$_attendee = $attendee_repo->get_attendee( $event_id, $contributor->ID );
if ( $_attendee instanceof Attendee ) :
echo '<form class="add-remove-user-as-host" method="post" action="' . esc_url( gp_url( "/events/host/$event_id/$contributor->ID" ) ) . '">';
if ( $_attendee->is_host() ) :
echo '<input type="submit" class="button is-primary remove-as-host" value="Remove as host"/>';
else :
echo '<input type="submit" class="button is-secondary convert-to-host" value="Make co-host"/>';
endif;
echo '</form>';
if ( current_user_can( 'edit_translation_event' ) ) :
$_attendee = $attendee_repo->get_attendee( $event_id, $contributor->ID );
if ( $_attendee instanceof Attendee ) :
echo '<form class="add-remove-user-as-host" method="post" action="' . esc_url( gp_url( "/events/host/$event_id/$contributor->ID" ) ) . '">';
if ( $_attendee->is_host() ) :
echo '<input type="submit" class="button is-primary remove-as-host" value="Remove as host"/>';
else :
echo '<span class="event-not-attending">' . esc_html__( 'Not attending', 'gp-translation-events' ) . '</span>';
echo '<input type="submit" class="button is-secondary convert-to-host" value="Make co-host"/>';
endif;
echo '</form>';
else :
echo '<span class="event-not-attending">' . esc_html__( 'Not attending', 'gp-translation-events' ) . '</span>';
endif;
endif;
?>
Expand All @@ -81,7 +79,7 @@
</ul>
</div>
<?php endif; ?>
<?php if ( ! empty( $attendees ) && ( ! $event->end()->is_in_the_past() || ( ( $attendee instanceof Attendee && $attendee->is_host() ) || current_user_can( 'manage_options' ) || $user->ID === $event->author_id() ) ) ) : ?>
<?php if ( ! empty( $attendees ) && current_user_can( 'edit_translation_event' ) ) : ?>
<div class="event-attendees">
<h2>
<?php
Expand Down

0 comments on commit 4c8de23

Please sign in to comment.