Suporte » Problemas no funcionamento » Pegar nome do usuario e apresentar na home

A visualizar 8 respostas - de 1 a 8 (de um total de 8)
  • Moderador Ze Fontainhas

    (@vanillalounge)

    Não estarás a complicar?

    <?php
    if ( is_user_logged_in() ) {
    
          $current_user = get_currentuserinfo();
    
          // Exemplos de utilização
          $user_login = $current_user->user_login;
          $user_email = $current_user->user_email;
          $user_nome = $current_user->user_firstname;
          $user_apelido = $current_user->user_lastname;
          $user_nickname = $current_user->display_name;
          $user_id = $current_user->ID;
    }
    ?>

    nao conheco esses modulos tem tudo pronto, vou testar obrigado, aviso resultado.

    nao escreveu nada! sera que falta algum arquivo?
    me loguei coloquei esse trecho na minha pagina principal nao deu erro, mas nao mostrou o login do usuario.
    A pagina principal nao carrega sessao tambem, pensei que era falta da tag de inicilizacao de sessao mas nao resolvel vejam o codigo o que falta?

    <?php
    session_start();
    ob_start(); 
    
    /**
     * The Header for our theme.
     *
     * Displays all of the <head> section and everything up till <div id="main">
     *
     * @package WordPress
     * @subpackage Twenty_Ten
     * @since Twenty Ten 1.0
     */
    ?><!DOCTYPE html>
    <html <?php language_attributes(); ?>>
    <head>
    <meta charset="<?php bloginfo( 'charset' ); ?>" />
    <title><?php
    	/*
    	 * Print the <title> tag based on what is being viewed.
    	 */
    	global $page, $paged;
    
    	wp_title( '|', true, 'right' );
    
    	// Add the blog name.
    	bloginfo( 'name' );
    
    	// Add the blog description for the home/front page.
    	$site_description = get_bloginfo( 'description', 'display' );
    	if ( $site_description && ( is_home() || is_front_page() ) )
    		echo " | $site_description";
    
    	// Add a page number if necessary:
    	if ( $paged >= 2 || $page >= 2 )
    		echo ' | ' . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );
    
    	?></title>
    <link rel="profile" href="http://gmpg.org/xfn/11" />
    <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
    <link rel="shortcut icon" href="<?php echo get_template_directory_uri(); ?>/images/favicon.ico">
    
    <?php
    	/* We add some JavaScript to pages with the comment form
    	 * to support sites with threaded comments (when in use).
    	 */
    	if ( is_singular() && get_option( 'thread_comments' ) )
    		wp_enqueue_script( 'comment-reply' );
    
    	/* Always have wp_head() just before the closing </head>
    	 * tag of your theme, or you will break many plugins, which
    	 * generally use this hook to add elements to <head> such
    	 * as styles, scripts, and meta tags.
    	 */
    
     wp_head();
    ?>
    
    <link href="<?php echo get_template_directory_uri(); ?>/css/topo.css" rel="stylesheet" />
    <link href="<?php echo get_template_directory_uri(); ?>/css/geral.css" rel="stylesheet" />
    
    <link href="<?php echo get_template_directory_uri(); ?>/css/conteudo.css" rel="stylesheet" />
    <link href="<?php echo get_template_directory_uri(); ?>/css/rodape.css" rel="stylesheet" />
    
    <link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri(); ?>/css/slider/style.css" />
    
    <link href="<?php echo get_template_directory_uri(); ?>/css/bootstrap.min.css" rel="stylesheet" />
    <link href="<?php echo get_template_directory_uri(); ?>/css/bootstrap-responsive.min.css" rel="stylesheet" />
    
    <script type='text/javascript' src='<?php echo get_template_directory_uri(); ?>/js/jquery.js'></script>
    <script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/js/slider/jquery-ui.1.5.3min.js" ></script>
    
    <script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/js/yepnope.1.0.2-min.js"></script>
    <script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/js/modernizr-2.0.6.min.js"></script>
    
    <script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/js/imgLiquid.js" ></script>
    
    <script type="text/javascript">
    //<![CDATA[
    /*********************************************************************************************************
    SLIDER
    *********************************************************************************************************/
    $(function(){
    	$("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
    });
    /*********************************************************************************************************
    NORMALIZADOR PARA IE
    *********************************************************************************************************/
    jQuery(function(){
    var $art = jQuery('#boxControles,#conteudo,#rodape,#menu,#busca,#hover1,#hover7,#hover8,#hover14');
    	yepnope({
    		load:'js/PIE.js',
    		complete : function(){
    			$art.each(function(){
    				PIE.attach(this);
    			});
    		}
    	});
    });
    /*********************************************************************************************************
    FORMATA IMAGEM
    *********************************************************************************************************/
    jQuery(function(){
    	 jQuery(".imgLiquidFill2").imgLiquid({fill:true});
    	 jQuery(".imgLiquidFill").imgLiquid({fill:false});
    	});
    /*********************************************************************************************************
    DEPENDENCIAS
    *********************************************************************************************************/
    jQuery(function(){
    	jQuery("#txtUser").attr("placeholder","Digite seu e-mail");
    	jQuery("#txtPassword").attr("placeholder","Senha");
    	jQuery("#txtMail").attr("placeholder","Coleque seu e-mail");
    	jQuery("#busca").attr("placeholder","O que esta procurando?").focus();
    
    	jQuery("#searchsubmit").attr("id","btnSubmitBusca");
    	jQuery("#searchform div").attr("id","estiliza");
    });
    /*********************************************************************************************************
    DEPENDENCIAS
    *********************************************************************************************************/
    jQuery(function(){
    	jQuery("#primary").append("<div id='tempo'>  <iframe src='<?php echo get_template_directory_uri(); ?>/weather/Forecasts.htm' width='180' height='150' frameborder='0' scrolling='no'></iframe>  </div>");
    
    	var url = window.location.href;
    		if (url.indexOf('<?php echo get_template_directory_uri(); ?>/wp-login.php') != -1) {
    			jQuery("#login p label").hide();
    			jQuery("#login p.submit").hide();
    			jQuery(".txtUser").attr("placeholder","Coloque seu login");
    
    		}
    
    	var url = window.location.href;
    		if (url.indexOf('<?php echo get_template_directory_uri(); ?>/wp-login.php?action=lostpassword') != -1) {
    			jQuery("#login p label").show();
    			jQuery("#login p.submit").show();
    			jQuery(".input").focus();
    			jQuery(".txtUser").attr("disabled","disabled");
    			jQuery(".txtPassword").attr("disabled","disabled");
    		}
    
    	var url = window.location.href;
    		if (url.indexOf('<?php echo get_template_directory_uri(); ?>/wp-login.php?action=register') != -1) {
    			jQuery("#login p label").show();
    			jQuery("#login p.submit").show();
    			jQuery(".txtUser").attr("disabled","disabled");
    			jQuery(".txtPassword").attr("disabled","disabled");	
    
    		}
    
    });
    //]]>
    
    </script>
    
    <?php
    //echo $_session['user_name'];
    
    		//require('http://www.meusite.com.br/wp-load.php');?>
    
    </head>
    
    <body <?php body_class(); ?>>
    
    <div id="fb-root"></div>
    <script>(function(d, s, id) {
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return;
      js = d.createElement(s); js.id = 346417145379717;
      js.src = "//connect.facebook.net/pt_BR/all.js#xfbml=1&appId=3v48";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>
    
    <div class="palavrasChaves"></div>
    	<div id="geral">
        	<div id="logo"> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="800" height="90" id="movie_name" align="middle">
                        <param name="movie" value="<?php echo get_template_directory_uri(); ?>/swf/spot.swf"/>
                        <param name="wmode" value="transparent" />
                        <!--[if !IE]>-->
                        <object type="application/x-shockwave-flash" data="<?php echo get_template_directory_uri(); ?>/swf/spot.swf" width="800" height="90">
                            <param name="movie" value="<?php echo get_template_directory_uri(); ?>/swf/spot.swf"/>
    
                            <param name="wmode" value="transparent" />
                        <!--<![endif]-->
                            <a href="http://www.adobe.com/go/getflash">
                                <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player"/>
                            </a>
                        <!--[if !IE]>-->
                        </object>
                        <!--<![endif]-->
                    </object> </div>
            	<div id="boxControles">
            		<div class="Saudacoes_info">
    
    					  <?php include("functions/saudacao.php"); ?>
                            </div>
                    <div class="Saudacoes_info slogan"><span class="destaq">meusite | Universo Sem Limites</span></div>
                    <ul class="contato">
                    	<li><span id="imgMail"></span></li>
                        <li class="contatoTxt"><a href="../contato/">CONTATO</a> </li>
                    </ul>
                    <div class="boxLeft">
                        <span id="imgUser"></span>
                            <ul class="onlineUser">
                                <li class="onlineUserNumber"><?php echo $random = rand (1, 4); ?></li>
                                <li class="onlineUserTxt">Visitantes</li>
                            </ul>
                                <div class="filete"></div>
    
                <form name="loginform" id="loginform" action="wp-login.php" method="post">
                  <input type="text" name="log" id="user_login" class="txtUser"/><!--id="txtUser"-->
                    <input type="password" name="pwd" id="user_pass" class="txtPassword"/><!--  id="txtPassword" -->
                        <span class="esqueciSenha">
                        <a href="<?php echo esc_url( site_url( 'wp-login.php?action=lostpassword', 'login_post' ) ); ?>">Esqueci Senha</a>
                        </span>
                            <input type="hidden" name="redirect_to" value="<?php #echo get_template_directory_uri(); ?>http://www.meusite.com.br/wp-admin/" />
                            <input type="hidden" name="testcookie" value="1" />
                            <input type="submit" value="." id="btnSubmit" />
                </form> 
    
                           <a href="" id="Gear"></a>
                    </div>                 
    
                    <div class="boxRight">
                    	<button id="cadastrese">CADASTRE-SE</button>
    
                        <form target="_blank" method="get" action="<?php //cidade(); ?><?php //echo esc_url( site_url( 'wp-content/themes/twentyten/functions/enviaNews.php', 'login_post' ) ); ?>" >
                          <input type="text" id="txtMail" name="txtMail" />
                          <input type="submit" id="btnSubmitMail" />
                        </form>
                    </div>
                  <div id="box_busca">
                    <!--<input type="text" id="busca"  />
                    <input type="submit" id="btnSubmitBusca" />
                        -->
    
                            <li id="busca" class="widget-container widget_search">
    							<?php get_search_form(); ?>
                            </li>
    
                  </div>
                <div class="both"></div>
                </div>
    
            <div id="conteudo">
            	<div id="menu">
    
    		<div id="access" role="navigation">
    			  <?php /* Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff */ ?>
    				<div class="skip-link screen-reader-text"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentyten' ); ?>"><?php _e( 'Skip to content', 'twentyten' ); ?></a></div>
    				<?php /* Our navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assiged to the primary position is the one used. If none is assigned, the menu with the lowest ID is used. */ ?>
    				<?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>
    			</div><!-- #access -->
    
                </div>        
    
    <img src="<?php echo get_template_directory_uri(); ?>/images/itens/einstein.png" class="einstein" width="134" height="279" alt="einstein" />
            	<div id="conteudoGeral">
    
    	<div id="main">
    
    		<div id="container">
    			<div id="content" role="main">
    Moderador Ze Fontainhas

    (@vanillalounge)

    <?php
    session_start();
    ob_start();
    ?>

    Isto não serve para nada. O WordPress já faz o seu próprio session_start.

    E não sei onde foste buscar esse tema, mas se isso é mesmo o header.php, tens problemas bem maiores do que o nome do utilizador…

    Oo tema foi criado por mim, que tipo de problema se SEO, semantica etc esta funcionando.
    Como resolvo isso pego nome do usuario logado e escrevo na home?
    Por que nao roda session?

    Moderador Ze Fontainhas

    (@vanillalounge)

    Por que nao roda session?

    Pelo que vejo no código não precisas da sessão para nada… o WordPress gere isso tudo nativamente, incluindo cookies de autenticação.

    Como resolvo isso pego nome do usuario logado e escrevo na home?

    Tal como explicado mais acima, por exemplo:

    <?php
    if ( is_user_logged_in() ) {
          $current_user = get_currentuserinfo();
          echo $current_user->display_name;
    }
    ?>
    Moderador Ze Fontainhas

    (@vanillalounge)

    que tipo de problema se SEO, semantica etc esta funcionando.

    O problema chama-se Coding Standards, particularmente na maneira como estás a incluir CSS e JS directamente no header.php. Lê a documentação de (pelo menos) wp_enqueue_script.

    nao escreve nada!! coloquei uma div vermelha e escrevi essa funcao dentro dela pra ter certeza da area que ia aparecer etc, nada nao da erro mas nao escreve, alguma ideia?

    Obrigado pela forca.

A visualizar 8 respostas - de 1 a 8 (de um total de 8)
  • O tópico ‘Pegar nome do usuario e apresentar na home’ está fechado a novas respostas.