0

我正在使用 mymodal 让我的用户登录他们的帐户,不幸的是,当用户登录时,它仍然显示相同的按钮和登录选项。如何在用户登录时将其更改为显示注销。此代码都在一个文件中。

<?php } ?>

<?php if($smof_data['disable_signin_btn'] !='disable') { ?>

<div class="button-second">

    <a href="#myModal2" role="button" class="btn btn-primary btn-small" data-toggle="modal"><?php _e('Sign In','siiimple') ?>&nbsp;&nbsp;<span class="icon-circle-arrow-right"></span></a>

    <div id="myModal2" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

        <div class="modal-header">

            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>

            <h3 id="myModalLabel2"><?php _e('Sign In','siiimple') ?></h3>

        </div><!-- END MODAL HEADER -->

        <div class="modal-body">

            <form method="post" action="<?php echo site_url(); ?>/wp-login.php" id="loginform_custom" class="form-horizontal" name="loginform_custom">

                <div class="control-group">

                    <label class="control-label"><?php _e('Username','siiimple') ?></label>

                    <div class="controls">

                            <input type="text" class="u-name" name="log" />

                    </div><!-- END CONTROLS -->

                </div><!-- END CONTROL GROUP -->

                <div class="control-group">

                    <label class="control-label"><?php _e('Password','siiimple') ?></label>

                    <div class="controls">

                        <input type="password" class="u-pass" name="pwd" />

                    </div><!-- END CONTROLS -->

                </div><!-- END CONTROL GROUP -->

                <div class="control-group">

                    <div class="controls">

                        <label class="checkbox">

                            <input type="checkbox"> <?php _e('Remember me','siiimple') ?>

                        </label>

                        <input type="submit" class="btn" name="submit" value="Login" /><div class="clear" style="clear:both"></div><a href="<?php echo site_url();?>/wp-login.php?action=register" class="register-modal"><?php _e('Register','siiimple') ?></a><a href="<?php echo wp_lostpassword_url(); ?>" title="Lost Password"><?php _e('Lost your password','siiimple') ?></a>
                    </div><!-- END CONTROLS -->

                </div><!-- END CONTROL GROUP -->
          <?php do_action( 'wordpress_social_login' ); ?> 

            </form><!-- END FORM -->

        </div><!-- END MODAL BODY -->

    </div><!-- END MODAL2 -->

</div><!-- END LIST -->

<?php } ?>

    <?php wp_nav_menu( array(
    'theme_location' => 'sub_menu',
    'sort_column' => 'menu_order',
    'menu_class' => 'sub-menu',
    'fallback_cb' => 'default_menu'
    )); 
?>
4

1 回答 1

1

使用is_user_logged_in()条件标签:

<?php
    if( is_user_logged_in() ) {
        // logout button
    } else {
        // login button + login form
    }
?>
于 2013-04-22T17:24:57.367 回答