PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Hide login link for members

s2Member Plugin. A Membership plugin for WordPress®.

Hide login link for members

Postby bennisb » March 28th, 2011, 9:51 am

Hi

At http://www.pensionforecast.org.uk, I have a member login link which I've put in the multimedia box. When a member logs in, I'd like to replace it with their name, so it says: Welcome FirstName. I think this is done with conditionals, but I don't know how or where to place the code needed. Can anyone help, please.

Thanks.

Brian
User avatar
bennisb
Registered User
Registered User
 
Posts: 11
Joined: March 22, 2011

Re: Hide login link for members

Postby Cristián Lávaque » March 28th, 2011, 12:31 pm

In your Login Welcome Page, you could try this:

Code: Select all
<?php
    $current_user 
= wp_get_current_user();
    echo esc_html($current_user->display_name);
?>


This assumes that the person is logged in, since its the Login Welcome Page, and that's why I'm not checking for that.

Also, you'll need this plugin for PHP code to work in your WP page https://wordpress.org/extend/plugins/exec-php/

Hope that helps. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Hide login link for members

Postby bennisb » March 28th, 2011, 1:29 pm

Dear Cristian

Thanks for your reply.

I installed the plugin you suggested. I added to the code to the top of the Login Welcome Page. I then got this warning...

Exec-PHP WYSIWYG Conversion Warning. Saving this article will render all contained PHP code permanently unuseful. Even if you are saving this article through the Code editor. You can turn off this warning in your user profile. Ignore this warning in case this article does not contain PHP code. Read the Exec-PHP documentation if you are unsure what to do next.

I deleted the code and didn't save the page!

Is this the right place for the code you suggest, given the only place I want to hide the login link is in the multimedia box in the right hand column - http://www.pensionforecast.org.uk (if the person is logged in).

Brian
User avatar
bennisb
Registered User
Registered User
 
Posts: 11
Joined: March 22, 2011

Re: Hide login link for members

Postby Cristián Lávaque » March 28th, 2011, 1:48 pm

I'm sorry, must have been half-asleep when I read your post, I was thinking you wanted to use the person's name to welcome him after login... :roll:

By the way, that error was just to let you know that if you use PHP code in the post, you shouldn't go back to the visual editor, just remain the code one.

OK, so you want the box on the right to change the login message if the person is logged in. Yes, conditionals will do the trick for you. Please read the documentation here WP Admin -> s2Member -> API / Scripting -> Advanced Query Conditionals

You'll be using the function is_user_logged_in(). So your code could be something like this:

Code: Select all
<?php
if 
(is_user_logged_in()) {
    echo '<p>Welcome', S2MEMBER_CURRENT_USER_FIRST_NAME, '!</p>';     
} else {
    echo '<p><a href="http://www.pensionforecast.org.uk/join-and-become-a-member/"><img src="http://www.pensionforecast.org.uk/images/member.gif"></a></p>',
         '<p><a href="http://www.pensionforecast.org.uk/wp-login.php?action=login">Member Login &raquo;</a></p>';
}
?>


Hope that helps. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Hide login link for members

Postby bennisb » March 28th, 2011, 4:19 pm

Hi Cristian

Thanks for your reply. I've added to the code to the multimedia box, but it displays a load of code on the page as you can see here - http://www.pensionforecast.org.uk/ Login works, but the code still remains. You can log in using test and test to see what I mean.

What can I do to correct the code, please?

Brian
User avatar
bennisb
Registered User
Registered User
 
Posts: 11
Joined: March 22, 2011

Re: Hide login link for members

Postby Cristián Lávaque » March 28th, 2011, 7:38 pm

Hmm... I had an error in the code, I fixed it now in my other post. Sorry about that. :P

The error wasn't what caused what you have coming up in your page, though. Could you show me what's around it in your code too?
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Hide login link for members

Postby drbyte » March 28th, 2011, 11:22 pm

Try this:

Code: Select all
<li>
    <?php if(is_user_logged_in()){ ?>
   <?php } else { ?>
    Returning Members?&nbsp;
<?php } ?>
   
   <?php if(is_user_logged_in()){ ?><?php global $current_user;
      get_currentuserinfo();
     echo '' . $current_user->display_name . "\n"; ?> - <?php } else { ?><?php } ?>
   
   
    <?php wp_loginout(); ?></a><span style="font-weight: normal;">&nbsp;| <?php if(is_user_logged_in()){ ?>
      <a href="https://www.yoursite.com/my-account">Your Account</a>
      <a href="https://www.yoursite.com/help-pro">Membership Help</a>
      and so forth

<?php } else { ?>
<?php } ?>
     </span></li>


Sam
User avatar
drbyte
Experienced User
Experienced User
 
Posts: 269
Joined: May 6, 2010

Re: Hide login link for members

Postby bennisb » March 29th, 2011, 3:08 am

Hi Guys

Thanks for your help, but neither quite works. Here's Cristian's...
Image

And here's drbyte's...
Image

Here's the code without either code suggestion...
Code: Select all
<center>
<a href="http://www.pensionforecast.org.uk/join-and-become-a-member/"><img SRC="http://www.pensionforecast.org.uk/images/member.gif" ></a>
<p>
<a href="http://www.pensionforecast.org.uk/wp-login.php?action=login" align="right"><strong>Member Login &raquo;</strong></a>
<p><br>
<INPUT TYPE="image" SRC="http://www.pensionforecast.org.uk/images/bec.jpg" >
<P>
<B>
>> GET OUR FREE EBOOK <<
<P>
PERFECT PENSION PLANNING
<p>
Answers to the 7 vital questions you must ask to build the best retirement income</b>
<P>
Enter your email address and hit GET IT NOW
<form method='POST' action='http://www.whoelsewantsto.com/cgi-bin/arp3/arp3-formcapture.pl'>
<div>
<input type='text' name='email' size='30' >
<input type='hidden' name='subscription_type' value='E'>
<p>
<INPUT TYPE="image" SRC="http://www.pensionforecast.org.uk/images/go.gif" height="20" ALT="Submit Form" hspace="0" vspace="0" border="0">
</div>
<input type='hidden' name='tracking_tag' value='PensionForecastFreeReport'>
<input type='hidden' name='id' value='67'>
<input type='hidden' name='extra_ar' value=''>
</form>
<p>
Your email address will never be shared</p></center>


It looks like this...
Image

Thanks.

Brian
User avatar
bennisb
Registered User
Registered User
 
Posts: 11
Joined: March 22, 2011

Re: Hide login link for members

Postby drbyte » March 29th, 2011, 4:40 am

hi

you need to place the code within the WP loop

are you using the codes inside your templates or using a WP page? Remember these are not short codes..so they wont work using the WP editor or a text side widget for that matter...unless you have one of them Php plugins where you can use Php inside a page or a widget....which i really DO NOT recommend

Sam

Well after looking at your site..you are using Thesis Themes...not sure if you have access to the theme itself to play with the code...If not then you are limited some how.....there are so many FREE and well done themes ...Check Jason themes ..they are well written and works well with S2...http://www.primothemes.com/category/premium-wordpress-themes/
User avatar
drbyte
Experienced User
Experienced User
 
Posts: 269
Joined: May 6, 2010

Re: Hide login link for members

Postby bennisb » March 29th, 2011, 10:42 am

Hi Sam

Thanks for the reply. I think I can make amendments through the Thesis custom file editors (custom.css and custom_funtions.php). I'm not a programmer, so I'm not sure how this would work. Thesis doesn't recommend playing with the code, just making changes through these files, so that when updates are done, the changes won't be lost. Any thoughts?

Brian
User avatar
bennisb
Registered User
Registered User
 
Posts: 11
Joined: March 22, 2011

Re: Hide login link for members

Postby Cristián Lávaque » March 29th, 2011, 6:45 pm

Yeah, it looks like you don't have PHP available where you're editing that. To use the functions file the theme provides, you'd need to know what hook to use, though, and I don't know them in Thesis.

Maybe you can use shortcodes there, though. Here's my shortcode version of what I gave you earlier.

Code: Select all
[s2If is_user_logged_in()]
   <p>Welcome [s2Get constant="S2MEMBER_CURRENT_USER_FIRST_NAME" /]!</p>
[/s2If]

[s2If !is_user_logged_in()]
   <p><a href="http://www.pensionforecast.org.uk/join-and-become-a-member/"><img src="http://www.pensionforecast.org.uk/images/member.gif"></a></p>
   <p><a href="http://www.pensionforecast.org.uk/wp-login.php?action=login">Member Login &raquo;</a></p>
[/s2If]


I hope that works for you. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Hide login link for members

Postby drbyte » March 29th, 2011, 8:40 pm

Before you edit your sidebar.php...first copy the entire code to a text file and save......

edit the file and add the code provided and save..

it should work...if not then edit your file and copy your backup and save...

There is a plug in where you can execute php into your widgets..i think it's called wp php widget

humm...here's the link: http://wordpress.org/extend/plugins/wp-php-widget/

Try this first..if it works then you don not have to edit any page..just add it like you add any side bar widget and add the code inside....:)

Good luck

Sam
User avatar
drbyte
Experienced User
Experienced User
 
Posts: 269
Joined: May 6, 2010

Re: Hide login link for members

Postby Cristián Lávaque » March 29th, 2011, 9:39 pm

Thank you for helping, Sam. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Hide login link for members

Postby bennisb » March 30th, 2011, 3:05 am

Hi Sam and Cristián

Thanks guys for all your help. You've been superb. It's very much appreciated.

Brian
User avatar
bennisb
Registered User
Registered User
 
Posts: 11
Joined: March 22, 2011


Return to s2Member Plugin

Who is online

Users browsing this forum: Google [Bot] and 2 guests

cron