Support

Account

Home Forums Front-end Issues Display sub field data only for logged in user

Solving

Display sub field data only for logged in user

  • I have a repeater field,i want to display sub field data only for logged in user
    how to?

    my field

    <?php if ( have_rows( ‘downloads_nhieu_phien_ban’ ) ) : ?>
    <?php while ( have_rows( ‘downloads_nhieu_phien_ban’ ) ) : the_row(); ?>
    <?php the_sub_field( ‘nhap_link’ ); ?>
    <?php the_sub_field( ‘ten_version_link’ ); ?>
    <?php endwhile; ?>
    <?php else : ?>
    <?php // no rows found ?>
    <?php endif; ?>

  • 
    if (is_user_logged_in()) {
      if (have_rows(... etc
    }
    
  • <?php
    if ( is_user_logged_in() ) {
    if ( have_rows( ‘downloads_nhieu_phien_ban’ ) ){
    while ( have_rows( ‘downloads_nhieu_phien_ban’ ) ) {
    the_row();{
    the_sub_field( ‘ten_version_link’ );
    the_sub_field( ‘nhap_link’ );
    else {
    ?><p>you must be logged in to view the form</p><?php }
    }
    }
    }
    }
    ?>
    my code but don’t work

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

You must be logged in to reply to this topic.