Support

Account

Forum Replies Created

  • If you ever come to London, I own you a nice lunch. 🙂

    It works!

    🙂

  • Ahemm.. what do you mean exactly ?

    I have the ACF ‘mustjoin’ in the page events for the plugin (you can also download the calendar, it’s free), then I’ve put the snippet between
    <!– EDITED etc –> and <–view more–>

    Sorry I have understood wrongly your reply. 😐

  • Filename single-day.php

    <?php
    /**
     * Month View Single Day
     * This file contains one day in the month grid
     *
     * Override this template in your own theme by creating a file at [your-theme]/tribe-events/month/single-day.php
     *
     * @package TribeEventsCalendar
     *
     */
    
    if ( !defined('ABSPATH') ) { die('-1'); } ?>
    
    <?php
    $day = tribe_events_get_current_month_day();
    ?>
    
    <?php if ( $day['date'] != 'previous' && $day['date'] != 'next' ) : ?>
    
    	<!-- Day Header demon controller 2 -->
    	<div id="tribe-events-daynum-<?php echo $day['daynum'] ?>">
    
    		<?php if ( $day['total_events'] > 0 && tribe_events_is_view_enabled( 'day' ) ) { ?>
    			<a href="<?php echo tribe_get_day_link( $day['date'] ) ?>"><?php echo $day['daynum'] ?></a>
    		<?php } else { ?>
    			<?php echo $day['daynum'] ?>
    		<?php } ?>
    
    	</div>
    
    	<!-- EDITED - show this part only if the user must join Events List -->
    
    <?php $current_user = wp_get_current_user(); ?>
    <?php global $user_login;
          get_currentuserinfo(); ?>
    <?php $lookforuser = get_field('mustjoin'); var_dump($lookforuser);var_dump(strpos($lookforuser, $user_login)); ?>
    <?php echo 'event exists<br/>';tribe_get_template_part('month/single', 'event') ?>
    <?php if (strpos($lookforuser, $user_login) !== false) { ?>
        <?php while ($day['events']->have_posts()) : $day['events']->the_post() ?>
        <?php tribe_get_template_part('month/single', 'event') ?>
        <?php endwhile; ?>
    <?php } ?>
    
    	<!-- View More -->
    	<?php if ( $day['view_more'] && tribe_events_is_view_enabled( 'day' ) ) : ?>
    		<div class="tribe-events-viewmore">
    			<?php
    				if($day['total_events'] > 1 || $day['total_events'] == 0) {
    					$events_label = __( 'Events ', 'tribe-events-calendar' );
    				} else {
    					$events_label = __( 'Event ', 'tribe-events-calendar' );
    				}
    			?>
    			<a href="<?php echo $day['view_more'] ?>">View All <?php echo $day['total_events'] . " " . $events_label ?> &raquo;</a>
    		</div>
    	<?php endif ?>
    
    <?php endif; ?>
  • if I use also the second snippet, I have for ALL days this

    string(17) "User1 User2 User3" int(0) event exists + the events names.

    without refreshing.

    With refresh, same stuff + 2 times the events names on the day that the event is planned.

  • Ok then, I have added this now :

    <?php $lookforuser = get_field('mustjoin'); var_dump($lookforuser);var_dump(strpos($lookforuser, $user_login));?>

    And when I navigate to the page, I have this in ALL the days :
    bool(false) bool(false)

    As soon as I refresh :

    string(17) "User1 User2 User3" int(0)
    Even on the days where there are not meetings.

    Now I will apply your second post and will post the differences.

  • If I use that dump, I receive an insane long reply from the page..
    Especially for the days where there is a meeting planned.
    Without refreshing of course.

    As soon as I refresh the page, I have the same dump + the event.
    that’s weird.. :/

    do you want me to post it ?

    Thank you.

  • Unfortunately it is for an intranet, and because is still underwork for the content I can’t..

    But if you want more information, I can run all the test you may need, and post the results here.

    Thank you

  • Hi there! Thank for your suggestion, but it doesn’t work yet.

    If I use the code you wrote above, I receive an error, which tells me that the second parameter should be an array for the script..

    Because it is a string, I have ended up using this code :

    <?php $current_user = wp_get_current_user(); ?>
    <?php global $user_login;
          get_currentuserinfo(); ?>
    <?php $lookforuser = get_field('mustjoin') ?>
    <?php if (strpos($lookforuser, $user_login) !== false) { ?>
        <?php while ($day['events']->have_posts()) : $day['events']->the_post() ?>
        <?php tribe_get_template_part('month/single', 'event') ?>
        <?php endwhile; ?>
    <?php } ?>

    And it works at 99.5%!
    The problem is when I open the calendar page, I can’t see anything.. as soon as I manually refresh the page, all the events (where I am supposed to join) appear.
    It seems it needs to re-collect the infos..
    How can I fix it? (I tried with different computers/browsers, no changes..) Thank you.

  • Hi VoiD2008, thank you for your reply.

    Unfortunately it doesn’t work, and my php knowledge is not good enough to fix it.
    I should insert a control to check if the array exists or not I think..

    If I use this code, that works only with one username in that field,

    <?php  
    global $current_user;
    get_currentuserinfo();
    
    if ($current_user->user_login == 'get_field(mustjoin)') { ?>
    	<?php while ($day['events']->have_posts()) : $day['events']->the_post() ?>
    <?php tribe_get_template_part('month/single', 'event') ?>
    <?php endwhile; ?>
    		<?php } ?>

    Everything works.

    Of course, with two usernames in the field, it doesn’t. But I don’t receive an error.. it just works as it should, because it checks for an username made by the 1st+2nd usernames together.
    With a
    var_dump( get_field('mustjoin') ); I receive this :
    string(17) "User1 User2 User3"

    Thank you for your help.

Viewing 9 posts - 1 through 9 (of 9 total)