wordpress widget in non-wordpress side bar?

Discussion in 'Customization & add-ons' started by mav2u, Mar 23, 2010.

  1. mav2u

    mav2u New Member

    Joined:
    Oct 8, 2008
    Messages:
    31
    I have a few pages that I created based off the wordpress site. How can I use the same wordpress side bar widget to function in a .php file copy of the wordpress site in another folder.

    I'm sure it can be done by calling the script or maybe something else. But it would be nice to just be able to call the same widget with the changes in the wordpress content folder to use it in an outside of wordpress .php page.

    Thanks
  2. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
  3. mav2u

    mav2u New Member

    Joined:
    Oct 8, 2008
    Messages:
    31
    Yeah, I know about the sign in, but it is a static block. I want to call info from a php just like the wordpress widget. That way if I make other pages that need to call that script in the side bar it does. Then I only have to update one script as I put some weblinks in the login area once they login they see those extra links.

    Basically, I want to mimic the functionality of the wordpress widget on an outside .php page based on the wordpress template.
  4. miso

    miso aMember Pro Customer

    Joined:
    Aug 22, 2006
    Messages:
    543
    As David mentioned, you'd have to hack the widget apart and take what you want from it, rewrite a lot of the code (as now you don't have access to wordpress functions and all) to use sessions and read member's status/info that way, etc, etc...
  5. mav2u

    mav2u New Member

    Joined:
    Oct 8, 2008
    Messages:
    31
    Well, maybe easier to explain what I want from that plugin to show on these other pages then. Maybe another way to do what I want.

    I like the wordpress plugin as when they log in I've added the links that show once they login. The default ones are the "members page", " "edit profile", and "logout". They only see these links in the little widget once they have logged in.

    I've added a couple of other links to those to show also. I would like to keep this functionality so that when they go over to other protected areas of the site with other content in the amember protected pages I can have the same type side info that is on the wordpress. A login box that once they login, then shows those same links that I put in there. I don't want to have to add this PHP in every page then have to come back and edit it every time. I would like to put a php call to a script so that I can put it somewhere else on the site and call that into the many pages through out the site on those other protected pages.

    Does this make sense? I wold like the ability to create just one php function for a login box area that once logged in shows their name and then the links I want to show to other pages that all members have access too, like their profile page, edit info page, logout, ect....

    How can I do this?
  6. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
  7. mav2u

    mav2u New Member

    Joined:
    Oct 8, 2008
    Messages:
    31
    I see how to add a login to any page. What I want to add is the info that once they are logged in shows the custom links for example. But it pulls those custom links from a central file.

    I don't want to have 20 custom pages for products ect... and when i need to add a link I need to open all 20 individual pages to make the change. Instead I could just open on, add the links and all of them are showing the new info in the the login box area just below their name after they have successfully logged in and are active members.
  8. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Sorry not sure I understood what you mean. Can you explain on example.
  9. mav2u

    mav2u New Member

    Joined:
    Oct 8, 2008
    Messages:
    31
    Okay, I will try to build an example here to show.

    _______________________________

    Login:
    Password:

    _______________________________

    Once logged in it would look like this

    _______________________________

    Welcome John Doe

    Links:
    • Members Page
    • Edit Info
    • Members Videos
    • Members Gallery
    • Members Downloads
    • LOGOUT

    _______________________________

    Once logged in it would show the hidden content taking them to the links created on a central file. This way I could paste the code in the side bar on any php page an have the login box with the links show once they loggin or as they surf from one area to another on the site.

    But I would like to call the code from central file where I can edit the info the shows up once they are logged in. So I have to only edit that one file and not every php file I made on the site with the login box.

    Basically I would like to mimic the wordpress login box plugin for .php pages outside of wordpress for amember areas.

    Does that help out clarify it a little more?
  10. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    I think what you want to do is to place your code in a file lets call it sidebar.php and then call it using an include tag from your other pages:

    include('sidebar.php');

    David
  11. mav2u

    mav2u New Member

    Joined:
    Oct 8, 2008
    Messages:
    31
    Yeah something like that. I'm not a php guru but I understand it some.

    Yes, something to that extent sounds like what I would like it to do. Then once they log in the the sidebar area then displays below their user name the custom navigation links.

    Not sure how to code the stuff to show the custom links and what have you after they login in though. Not a PHP guru guy.
  12. mav2u

    mav2u New Member

    Joined:
    Oct 8, 2008
    Messages:
    31
    Anyone know how I can do this? I would really like to add this to the pages.
  13. miso

    miso aMember Pro Customer

    Joined:
    Aug 22, 2006
    Messages:
    543
    Umm, yeah. Hire someone to do it for you instead of spending days trying to figure it out on your own ;)

    Just saying.
  14. mav2u

    mav2u New Member

    Joined:
    Oct 8, 2008
    Messages:
    31
    Okay, finally had time to look this up. If you take the below code as provided a sticky on the forums.
    PHP:
    <?php
    session_start
    ();
    if (
    $au=$_SESSION['_amember_user']){ // user is logged-in
      
    print "Hello $au[name_f] $au[name_l]!<br>";
      print 
    "<a href='/amember/logout.php'>Logout</a>";
    } else { 
    // user is not logged-in
      
    print "<form method=post action='/amember/login.php'>
      Username: <input type=text name=amember_login size=10><br>
      Password: <input type=password name=amember_pass size=10><br>
      <input type=submit value='Login'>
      </form>"
    ;
    }
    ?> 
    Then below the logout or above just add another line with your link info in there for general linking. I suppose you could also make it so it reads out based on a particular subscription but I don't need that right now.
    PHP:
    print "<a href='/amember/logout.php'>Logout</a>";
    print 
    "<a href='http://www.mysite.com/secretfolder/'>User Folder</a>"<br>;
    Okay, so how do I call this from an external php file? Any recommendations on where to place this file for protection and how to call it properly an remain secure?

Share This Page