Full integration - aMember & WordPress

Discussion in 'Templates customization' started by miso, Apr 15, 2008.

  1. miso

    miso aMember Pro Customer

    Joined:
    Aug 22, 2006
    Messages:
    543
    Oh man, I've just figured it out now... wow, and all this info was available out there, and I've used a lot of it, but never put two and two together.

    So, after all the useless patching and trying to incorporate php code into smarty templates and vice versa, I've finally done it.

    I am not sure what the implications of it are as far as security goes, but to be quite honest, I really don't care... it looks good to me as it is!

    So, what I've done is this... quite simple.

    If you have a wordpress powered website, and a theme/template already developed, here's what you do:

    Step 1
    Open up your /amember/config.inc.php
    Assuming that your wordpress is installed in the root folder, and amember in a subfolder, you add these two lines just before the last closing curly bracket, or at the end of the file to be safe after all the brackets and whatnot:

    Code:
    define('WP_USE_THEMES', false);
    require("../wp-blog-header.php");
    
    Step 2
    Open up page.php in your wordpress theme folder.
    If it hasn't been customized heavily, and looks pretty much like the default themes look like, copy the first line or two that call the header info:

    Code:
    <?php get_header(); ?>
    
    	<div id="main">
    and paste them into your amember's header.html (in templates folder), overwriting all the amember code (except for the calls to CSS files, you might wanna save those and paste them right after the code below):

    Code:
    {php}get_header();{/php}
    
    	<div id="main">

    Step 3

    Do the same for your footer.html as well - copy the closing code from your page.php:

    Code:
    	</div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>
    into the footer.html like this (overwriting all that code in there):

    Code:
    	</div>
    
    {php}get_sidebar();{/php}
    
    {php}get_footer();{/php}
    And from there on, it would be nice if you integrated the amember-sidebar-widget wordpress plugin from one of the members here (also posted on www.wordpress.org/extend/plugins) and plug that into your sidebar, thus giving users quick access to the login/logout/member links (I've customized that widget quite a bit, listing affiliate links as well and styling it in a custom fashion).

    And you're set!

    All you have to do from now on is update/change your wordpress templates and your amember templates will be automatically updated too... just stupid easy.

    All I'm having a problem right now is properly integrating $title variables from smarty templates into the pages, so I've actually created a custom header2.php file in wordpress to get around this issue, until I run into a better solution.
  2. miso

    miso aMember Pro Customer

    Joined:
    Aug 22, 2006
    Messages:
    543
    the only problem I see with this method of integration is when I try to logout, and logout.php file gives me this error:

    Code:
    Fatal error: Call to a member function assign() on a non-object in /home/naturals/public_html/members/common.inc.php on line 1250
    in function html_redirect and it has something to do with the redirect page that should get displayed, even though I get logged out just fine, as far as cookies/session goes.
  3. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    This is a great tip. I tested this and it works great under WordPress 2.5, with the exception of actually being able to login?? I'm not quite sure if session is not being established or what the deal is..
  4. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    Was anyone able to get this working? I'd love to automate this as part of a plugin.
  5. miso

    miso aMember Pro Customer

    Joined:
    Aug 22, 2006
    Messages:
    543
    for that you should use the updated Wordpress Plugin from aMember (they updated it for wordpress 2.5)
  6. darren

    darren Member

    Joined:
    Aug 22, 2006
    Messages:
    36
    Did anyone else have issues logging into the admin section? I get the following error

    Fatal error: require() [function.require]: Failed opening required '../wp-blog-header.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/attitra/public_html/members/config.inc.php on line 56

    This is line 56

    Code:
    require("../wp-blog-header.php");
    The crazy thing is that I can access the signup form and login areas just fine but if I try to go to the admin section it gives me the error. Could it be that the admin section is one folder "deeper" /member/admin/?
  7. miso

    miso aMember Pro Customer

    Joined:
    Aug 22, 2006
    Messages:
    543
    In that case I would just edit config.php and change that require("../wp-..."); into a full path to the file.

    And again, the only problems I run into with this set up is errors on logout (can't figure out how to get around it) and occasionally the admin backend throws me the frontend layout in the right-hand frame (on an error or something)... which I can deal with, as nobody but me sees it.
  8. darren

    darren Member

    Joined:
    Aug 22, 2006
    Messages:
    36
    Thanks. I tried that between the time I made the post and now, but didn't try "/home/attitra/public_html/wp-blog-header.php" and that worked. However, now I am not able to login to the membership area. The login page is there and I even have a custom page to login but neither of them work. Very strange as it doesn't work in IE or Mozilla. Any suggestions?
  9. matthewebel

    matthewebel Minister of Piano Rock

    Joined:
    Jul 13, 2008
    Messages:
    22
    Signup page not parsing correctly now.

    I tried adding the following to the end of my config.inc.php file:
    Code:
    define('WP_USE_THEMES', false);
    require("/the/complete/path/to/wp-blog-header.php");
    And changed the header to:
    Code:
    {php}get_header();{/php}
    <DIV ID="aMemberBody">
    And the footer to:
    Code:
    </DIV>
    
    {php}get_sidebar();
    
    get_footer();{/php}
    And the strangest thing happened... my signup page stopped working. Other pages (the login page, the index, etc.) parse the language tags and make it all the way to the footer, but for some reason this is what I get with my signup:
    [​IMG]
    I can't for the life of me figure out why this file isn't parsing properly, but others are. I've switched my wordpress theme back to the default, but that didn't help.

    Any ideas? Anyone else have this issue?
  10. pattygale09

    pattygale09 New Member

    Joined:
    Aug 22, 2006
    Messages:
    2
    I am finding that this is not working with a widgetized sidebar. I'm using the exact code posted in this forum and the footer code is picking up my widgets instead of the footer.
  11. mfaxion

    mfaxion New Member

    Joined:
    Jul 2, 2008
    Messages:
    6
    anyone figure this out?
  12. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    I find it much easier to make a hard coded template based on the blog. You mainly need to focus on the header and footer.

    David
  13. budhimind

    budhimind New Member

    Joined:
    Jun 13, 2008
    Messages:
    2
    wordpress display smarty variables

    I have figured out to display {$title} in wordpress. The code is listed bellow:
    Code:
    wp header.php file
    
    <?php if (substr($_SERVER["REQUEST_URI"], 1, 7) == 'amember') { ?>
    <title>aMember only | <?php global $t; echo $t->get_template_vars('title'); ?></title>
    <link rel="stylesheet" ....add amember CSS here/>
    <?php } else { ?>
    <title><?php wp_title(''); ?><?php if(wp_title('', false)) { echo ' |'; } ?> <?php bloginfo('name');?></title>
    <?php } ?>
    
    
    works great!!
    Thanks every one for sharing:)
    John
  14. ryanthelion

    ryanthelion New Member

    Joined:
    Oct 3, 2008
    Messages:
    3
  15. budhimind

    budhimind New Member

    Joined:
    Jun 13, 2008
    Messages:
    2
    give absolute path will be OK

    I fixed it and thanks for point out,
    Something like "/home/userxxx/public_html/wp/wp-blog-header.php":)
    John
  16. ryanthelion

    ryanthelion New Member

    Joined:
    Oct 3, 2008
    Messages:
    3
  17. aramtch

    aramtch New Member

    Joined:
    Oct 13, 2009
    Messages:
    11
    hey guys... reviving a semi-old thread...

    I've followed the steps, but i get:

    Fatal error: Call to undefined function get_header() in /domains/xxxxxxxxxxx.com/html/amember/templates_c/%%190^%%1901021975^header.html.php on line 26

    Any direction would be a huge help.
  18. microvb

    microvb Member

    Joined:
    Nov 23, 2007
    Messages:
    62
    There is an easy fix which is not dependent on your root directory:

    Code:
    		define('WP_USE_THEMES', false);
    		require("$config[root_dir]/../wp-blog-header.php");
    
    Enjoy.
  19. miso

    miso aMember Pro Customer

    Joined:
    Aug 22, 2006
    Messages:
    543
    Nice.

    That still needs to be edited in case your wordpress/blog is in a different folder... but still nice.
  20. agadmin1

    agadmin1 New Member

    Joined:
    Jan 15, 2009
    Messages:
    3
    I'm getting two error msgs when I try to do this...

    1) WARNING: in_array() [function.in-array]: Wrong datatype for second argument in line 123 of file plugins.inc.php
    2) Plugin 'wordpress' is not enabled. Died

    I've tried everything on this thread... any ideas?

Share This Page