Archived

This topic is now archived and is closed to further replies.

  • 0

Add login/register in Branding with Hook


Question

Posted · Report post

I have added the following function to  pagelines-customize/functions.php. I want to add conditional Login/out and register to the left of the social icons in branding.
I have then styled the "header-login" class with Css in style.less

ISSUE: It is not showing up at all. It is my firstt-time using Hooks and I thought I had followed all the FAQS etc closely, but what am I doing wrong?


add_action('pagelines_before_branding_icons', 'add_loginlogout');
function add_loginlogout() { ?>
<div class="header-login">"
	<?php if(is_user_logged_in()): ?>
	<a href="<?php echo wp_logout_url( get_permalink() ); ?>" title="Logout">Logout</a>
	<?php endif; ?>
	<?php if(!is_user_logged_in()): ?>
	<a href="<?php echo wp_login_url(); ?>" title="Login">Login</a> | <a href="http://focusforhumanity.org/ffh_registration/">Register</a>
	<?php endif; ?>
</Div><?php 
}

Share this post


Link to post
Share on other sites

7 answers to this question

Posted · Report post

Sure

I had all sorts of problems with the CSS styling correctly when I used "pagelines_branding_icons_start" so I switched to "Pagelines_after+branding_wrap"

Action Map plugin very helpful in working out which one to use.

I didnt end up using "hooker", just updated the Functions.php file in the "wp-Content>plugins>Pagelines-customisation>" folder

See the working code below. It also includes Welcome back, edit profile and logout options

/*
// ===========================================================================
// LoginLogout  = Flips between whether Login/register or Edit Profile/Logout
// Placed in hook Pagelines_after_branding_wrap and then positioned using 
// absolute positioning in front of the Social icons
//
// I am also using UPME WP plugin to bring all WP registration to frontend and hence 
// using pages (ffh-Login & ffh-Registration & Edit-profile)) that calls the 
// UPME shortcode in pages of that name. You could just use the standard WP pages
// ===========================================================================
*/


add_action('pagelines_after_branding_wrap', 'loginlogout');
function loginlogout() { ?>

<div class="header-login">
  <?php if(is_user_logged_in()): 
  	$user = wp_get_current_user();?>
	Welcome back <span style="color:#FFAA33"><?php echo $user->display_name; ?> </span>
  	<a href="http://www.your URL.org/edit-profile/">Edit Profile</a>&nbsp;|&nbsp;<a href="<?php echo wp_logout_url( get_permalink() ); ?>" title="Logout">Logout</a>
 	 <?php endif; ?>
  <?php if(!is_user_logged_in()): ?>
  	<a href="http://www.yourURL.org/ffh-login/">Login</a>&nbsp;|&nbsp;<a href="http://www.yourURL/ffh-registration/">Register</a>
  <?php endif; ?>

 <div style="clear:both"></div>
 </div>
<?php 
}

Share this post


Link to post
Share on other sites

Posted · Report post

THanks - i've made the changes you suggested but nothing (ie my login/Logout/register) at all appears in the Branding section still

Share this post


Link to post
Share on other sites

Posted · Report post

When you used the Action Map, did it point you to the correct hook? If so, which one is it?

 

When using hooker, what did you add to that hook, exactly? Can you paste the code added?  Thanks.

Share this post


Link to post
Share on other sites

Posted · Report post

So you got it working then?

Share this post


Link to post
Share on other sites

Posted · Report post

Yes - thanks 

http://www.focusforhumanity.org   (Home page, iconography and images are still just placeholders, but focused on functionality at the moment which is coming along nicely. Put all of this together over 3 days using page lines . I'm impressed!)

 

 

Now playing around with other plugins to jazz up user registration, custom fields, integration with gravity forms etc... but the page lines is working fine....except for responsive design....when I view on mobile the positioning of the login/register is screwed up (Tackle that battle another day unless you have a suggestion)

Share this post


Link to post
Share on other sites

Posted · Report post

Excellent, thats great news.

 

You can ajust the mobile position of the login/register using @media commands in the css, or by using browser specific css via our plugin, which adds a class for each browser. 

 

See http://www.pagelines.com/store/plugins/browser-css/ to download the plugin and http://support.pagelines.me/docs/plugins/browser-specific-css/ for instructions and a list of the classes which can be used. If you get stuck or need further help, open a new topic as once a topic gets marked resolved/answered the moderator team don't see it as a new question in the queue. I clikced on this one by chance when catching up with the days topics etc, just to make sure your question isn't missed if you try to respond to this etc :-)

1 person likes this

Share this post


Link to post
Share on other sites

Posted · Report post

Try this hook: pagelines_branding_icons_start

 

And I'd recommend renaming the function from add_loginlogout  to just loginlogout. 

 

Did you use our Action Map plugin (free in our Store > Plugins > Top Free)?  Have you considered using our Hooker plugin?  It's a fantastic way of adding a hook without writing the code to functions.php. You just select the hook and drop in the code for the function.

Share this post


Link to post
Share on other sites