2

For a few hours I try to show a message only if there is a gallery Picu, without success, an idea?

Have try this code, but not work:

    /**
 * galeries content
 */
function iconic_galeries_endpoint_content() {
    echo /* Template Name: Client Area */

get_header();
?>

    <div id="primary" class="content-area">
        <main id="main" class="site-main">
        <section>
        <header class="entry-header">
                    <h1><?php _e( 'Photos gallery.', 'my-theme' ); ?></h1>
                </header>
            <article>

                <div class="entry-content">
                <?php
                $current_user = wp_get_current_user();

                if ( isset( $current_user->user_email ) ) {
                    echo '<p>' . sprintf( __( '%s, here is your client area', 'my-theme' ), $current_user->display_name ) . ':</p>';

                    if($output == '<li class="picu-status-' . get_post_status() . '"><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>') echo '<div class="woocommerce-MyAccount-content">
    <div class="woocommerce-notices-wrapper"></div>
    <div class="woocommerce-Message woocommerce-Message--info woocommerce-info">
        Your gallery.   </div>

</div>';
else echo $output;

                    $output = do_shortcode( '[picu_list_collections email="' . $current_user->user_email . '"]' );

// the shortcode returns an empty <ul> tag, if there is no gallery 
// https://plugins.trac.wordpress.org/browser/picu/trunk/frontend/includes/picu-template-functions.php#L464

if($output == '<ul class="picu-collection-list"></ul>') echo '<div class="woocommerce-MyAccount-content">
    <div class="woocommerce-notices-wrapper"></div>
    <div class="woocommerce-Message woocommerce-Message--info woocommerce-info">
        There is no gallery.    </div>

</div>';
else echo $output;
                }

                ?>
                </div>
            </article>
            </section>
        </main>
    </div>

<?php
}

Thanks in advance Nico

3
  • 2
    Where is $output first set? It looks like your are checking the value before it's set in your example code. Perhaps you need do_shortcode() at the beginning of your function. Commented Apr 3, 2019 at 13:42
  • How is that function being called? What's the problem you're trying to solve with this solution?
    – Tom J Nowell
    Commented Apr 3, 2019 at 13:51
  • In fact, gallery user is displaying if user email is find. But if user have no gallery, shortcode is not displaying and I would put a message like: Sorry, you have no gallery for the moment. Commented Apr 3, 2019 at 13:59

1 Answer 1

2

Try this:

<article>

                <div class="entry-content">
                <?php
                $current_user = wp_get_current_user();

                if ( isset( $current_user->user_email ) ) {
                    echo '<p>' . sprintf( __( '%s, here is your client area', 'my-theme' ), $current_user->display_name ) . ':</p>';


                    $output = do_shortcode( '[picu_list_collections email="' . $current_user->user_email . '"]' );

                    // the shortcode returns an empty <ul> tag, if there is no gallery 
                   // https://plugins.trac.wordpress.org/browser/picu/trunk/frontend/includes/picu-template-functions.php#L464

                   if($output == '<ul class="picu-collection-list"></ul>') {
                        echo '<div class="woocommerce-MyAccount-content">
                                 <div class="woocommerce-notices-wrapper"></div>
                                 <div class="woocommerce-Message woocommerce-Message--info woocommerce-info">
                                   There is no gallery.
                                </div>
                             </div>';
                   }
                   else {
                       echo '<div class="woocommerce-MyAccount-content">
                                <div class="woocommerce-notices-wrapper"></div>
                                <div class="woocommerce-Message woocommerce-Message--info woocommerce-info">
                                    Your gallery.
                                </div>
                         </div>';
                       echo $output;
                  }
  }

                ?>
                </div>
            </article>
1
  • once again thank you, you have just, very very thanks !! Commented Apr 3, 2019 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.