Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    May 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question PHP If Statement Help (Wordpress)

    Hi All,

    I'm currently using the s2member plugin for wordpress to allow me to create a client portal where users can log in and visit their own secure unique page. (This uses custom capability and the page must be called the same as their username.)

    But then i also have people that just log on to view my blog and are not clients and do not have pages created for them.

    I have the following code:

    PHP Code:
    <a href="?php echo S2MEMBER_CURRENT_USER_LOGIN; ?>/">Client Area</a
    This works fine when logged in as a user who has a page created but gives an 404 error for a user that does not have a page.

    My question is:

    Could the above code be wrapped in an if statement to say that if the S2MEMBER_CURRENT_USER_LOGIN does not = post_name then redirect them to the home page?

  • #2
    New to the CF scene
    Join Date
    May 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I doubt this is correct.

    But i need something like this:

    Code:
    $S2MEMBER_CURRENT_USER_LOGIN = username;
    
    if ( $username == post_name ) {
    	header( 'Location: http://www.yoursite.com?username' ) ;
    
    } else {
    	header( 'Location: http://www.example.com/home' ) ;
    
    }
    to link in with:

    Code:
    <a href="?php echo S2MEMBER_CURRENT_USER_LOGIN; ?>/">Client Area</a>

  • #3
    New to the CF scene
    Join Date
    May 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi All,

    I now have the following code
    Code:
    <a href="<?php echo (defined('S2MEMBER_CURRENT_USER_LOGIN') ? S2MEMBER_CURRENT_USER_LOGIN : post_name);?>/">Client Area</a>
    But it's still not redirecting the user if they don't have a page created?

    Any help would be great!

  • #4
    New to the CF scene
    Join Date
    May 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have now solved this issue. - Please close.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •