Jump to content


Photo
- - - - -

Login and Register link in header.

login register header brandin

Best Answer Rob , 08 February 2013 - 09:07 PM

Hi

 

No. You can use a javascript.  I do that on my own site... saying Good Morning (between midnight and noon), Good afternoon, and Good evening, based on the local time of the user's machine.  Doesn't depend on login either.  Here's that javascript. I'm also including one that gives the date:

 
<strong><script language="JavaScript">
var myDate = new Date();
/* hour is before noon */
if ( myDate.getHours() < 12 )
{
    document.write("Good Morning!");
}
else  /* Hour is from noon to 5pm (actually to 5:59 pm) */
if ( myDate.getHours() >= 12 && myDate.getHours() <= 17 )
{
    document.write("Good Afternoon!");
}
else  /* the hour is after 5pm, so it is between 6pm and midnight */
if ( myDate.getHours() > 17 && myDate.getHours() <= 24 )
{
    document.write("Good Evening!");
}
else  /* the hour is not between 0 and 24, so something is wrong */
{
    document.write("I'm not sure what time it is!");
}</script></strong><br />Today is... <SCRIPT LANGUAGE="JavaScript">
 
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!--  Author: www.cgiscript.net  -->
 
<!-- Begin
 
// Get today's current date.
var now = new Date();
 
// Array list of days.
var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
 
// Array list of months.
var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
 
// Calculate the number of the current day in the week.
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
 
// Calculate four digit year.
function fourdigits(number) {
    return (number < 1000) ? number + 1900 : number;
                                }
 
// Join it all together
today =  days[now.getDay()] + ", " +
         months[now.getMonth()] + " " +
         date + ", " +
         (fourdigits(now.getYear())) ;
 
// Print out the data.
document.write(today);
 
//  End -->
</script>.
Go to the full post


  • Please log in to reply
10 replies to this topic

#1 kellid

kellid

    Super Member

  • Members
  • 208 posts
  • Country: Country Flag

Posted 25 January 2013 - 08:57 PM

Hello!

 

I'm using s2member for my site and I'd like to add a simple "Log in" and "Register" link in the header on the top right above the social Icons.  I've seen a few posts, mostly outdated and more than I need.  I know I need to add a hook to my platformbase functions file but the exact code is where I'm stuck.  

 

Is this in the ballpark?

 

 

<?php } ?>

<li><h1>Meta</h1>


<ul class="headerlinks">


<li><?php wp_register(); ?></li>


<li><?php wp_loginout(); ?></li>


</ul>


</li>


<?php endif; ?>

 

Thanks in advance for your help!!

 

Kelli



#2 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 25 January 2013 - 09:19 PM

Hi Kelli,

 

First, let me start out by saying that since PlatformPro is now a deprecated product and will not be updated again, it might be more prudent to upgrade to PageLines Framework. Very few of our support team have much experience with PlatformPro these days and thus supporting it is incredibly difficult, as you can imagine with any outdated product. 

 

I cannot answer your code question for the simple reason that I'm not a programmer, but it seems you're using code from a Meta sidebar. I can say that the code you provided will not work because it doesn't end PHP first, then re-open it at the end.  Instead, it opens and closes PHP at the beginning, which will leave PHP open in the hook.  I can also say you're including a list item at the start without identifying whether it's an unordered or ordered list.  That will throw a wrench in the works.

 

I think if you look through the available resources for s2Member, you may find a shortcode or PHP for the login code.

 

A hook may be added to functions.php in PlatformBase.  Please see these instructions:

Please Login or Register to see this Hidden Content



#3 kellid

kellid

    Super Member

  • Members
  • 208 posts
  • Country: Country Flag

Posted 25 January 2013 - 11:10 PM

Thank You!!  I have made the upgrade to Pagelines Framework!! I appreciate you taking the time to respond.  I see now that I should have used something like this if I were adding this to the meta sidebar.  I wasn't sure if I should look to s2member first but will do so now.  I am (as you can see) just about clueless when it comes to coding but I'm doing my best to figure this out.  

 

I will use what you've given and make this work.  

 

Thanks again!!



#4 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 25 January 2013 - 11:26 PM

Glad to have helped.  I can say there are plugins that let you post the login form in the sidebar as a widget.  I've used one of these with s2Member in the past with great results.



#5 kellid

kellid

    Super Member

  • Members
  • 208 posts
  • Country: Country Flag

Posted 07 February 2013 - 02:09 AM

Hello,

 

So I've added a custom login form to my header.php file with some nifty info from

Please Login or Register to see this Hidden Content

but I can't figure out how to change the "Log In" link to the something like "Hello Jane" or "Hi Username" after they've logged in.  Any idea how?  Here is what I have...

 

 

 

<?php pagelines_register_hook('pagelines_before_header');?>
            <header id="header" class="container-group">
            <ul class="headerlinks">
<li><?php wp_register(); ?></li>
          <!-- here comes the important part -->
 <!---------------------------------------  DROPDOWN LOGIN CODE STARTS HERE      ---------------------------------------------->
 <style type="text/css">
 .dropdown.open .dropdown-menu {
    display: block;
    padding: 20px !important;
}
 </style>
           <li class="dropdown" id="menu1">
             <a class="dropdown-toggle" data-toggle="dropdown" href="#menu1">
               Login
                <b class="caret"></b>
             </a>
             <div class="dropdown-menu">
<?php
if ( ! is_user_logged_in() ) { // Display WordPress login form:
    $args = array(
        'redirect' => admin_url(), 
        'label_username' => __( 'Username' ),
        'label_password' => __( 'Password' ),
        'label_remember' => __( 'Remember Me!' ),
        'label_log_in' => __( 'Log Me In' ),
        'remember' => true
    );
    wp_login_form( $args );
} else { // If logged in:
    wp_loginout( home_url() ); // Display "Log Out" link.
    echo " | ";
    wp_register('', ''); // Display "Site Admin" link.
}
?>
           </li>
 <!---------------------------------------  DROPDOWN LOGIN CODE ENDS HERE      ---------------------------------------------->

 



#6 kellid

kellid

    Super Member

  • Members
  • 208 posts
  • Country: Country Flag

Posted 07 February 2013 - 02:11 AM

Here is a link...

 

Please Login or Register to see this Hidden Content



#7 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 07 February 2013 - 02:32 AM

Hi Kelli

 

I believe that to do this, you're going to need one of

Please Login or Register to see this Hidden Content

as this will require a customized cookie calling information from the login action by the user stored in the browser and/or the database to display. 

 

For example, if ja1234 is the login, but the member's first name is Jane, you don't want it to say "Hello ja1234" but "Hello Jane".  Since the first name is normally not stored in the browser cookie, either you need one that does store it, or, you need to match the user ID to the database to the first name field.   Then, there are serious security considerations - preventing hacking is important, particularly if members use credit or debit cards in their accounts.  You may also want to integrate javascript too, so that it says "Good Morning Jane" depending on the time of day.

 

There may be plugins for this, but I'm not personally familiar with them. I don't know of anything that does it all.  This is why I seriously recommend a Pro.  Unfortunately, we can't provide this kind of customization via the forum. I'm sure you understand.


  • kellid likes this

#8 kellid

kellid

    Super Member

  • Members
  • 208 posts
  • Country: Country Flag

Posted 08 February 2013 - 07:06 PM

Hey Rob,

 

Thanks again greatly for responding.  Your input is always informative, specific and helpful.  I will contact a pro if I decide to take that route.  One last question.  How about if I just want to change the Login Link to "Hello!"  "Good Day"  Something general that wouldn't need database information?  



#9 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 08 February 2013 - 09:07 PM   Best Answer

Hi

 

No. You can use a javascript.  I do that on my own site... saying Good Morning (between midnight and noon), Good afternoon, and Good evening, based on the local time of the user's machine.  Doesn't depend on login either.  Here's that javascript. I'm also including one that gives the date:

Please Login or Register to see this Hidden Content


  • kellid likes this

#10 kellid

kellid

    Super Member

  • Members
  • 208 posts
  • Country: Country Flag

Posted 08 February 2013 - 09:20 PM

:) As always, a major help.  

 

Thank You, Rob!!



#11 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 08 February 2013 - 09:29 PM

In that case, I'll resolve the topic!

 

Glad to help any time!


  • kellid likes this