Hello All, I've seen many asking the question of how to include WordPress templates into their aMember Signup, products..etc pages. Since it is something I was planning on doing anyway, I figured I would look into it. Explanation aMember uses .html file based templates to allow us to customize the templates. Since .html files are not designed to execute php code, there is no way to include WordPress header.php and footer.php. The solutions I've seen people talk about have been to copy and paste the resulting html from WordPress into the header.html and footer.html. For me, this is a poor implementation since it eliminates the ability to have a dynamic template. I know in my case, I have a completely dynamic website and I know that I am allergic to static pages. Static templates gives me a rash for some reason. Solution Without access to aMember code, it would be little difficult to force aMember to use .php based templates instead of .html templates, so the solution is to force .html files to behave as .php files. This is pretty simple implementation, but do keep in mind that I don't really have the luxury of time to make the solution "pretty" for everyone. Here is what you have to do: 1. Edit .htaccess file on your site, or create a new .htaccess under amember folder. 2. Add the following code to the file. PLEASE NOTE: Do not replace an existing .htaccess! append to it, or if does not exist create it. PHP: AddType application/x-httpd-php .html Now you have PHP enabled aMember templates. Open header.html, footer.html, or any other template file you like and add your PHP code to the files. Things to consider You really should only apply the "AddType" code above to specific template files, but I don't have the time to demo it. You need to look into your CMS system to see what is required for their templates to run. You will need to include some config files, but again I will leave it to someone with time on their hand to figure it out. Make sure your html files do not have any code that has <? tag in it, unless it is a PHP code or the template will give errors. That us why it is best to apply the type to specific files. If someone spends the time and integrates WordPress header, footer, and sidebar before I get to it, do share. Saves me few hours of investigation.
You know... you can scratch all that I said, I realized that there is {php}{/php} tag in templates, so you can accomplish the same thing. I got somewhere, but I ran into cookies problems, and became difficult to proceed so I stopped due to time. Here is what I found: open header.html and add the following to the top of the file: Code: {php} // Include Wordpress define('WP_USE_THEMES', true); require('../wp-blog-header.php'); get_header(); {/php} if you get an error in wp-settings.php line 216, it is due to $wpdb losing its scope/value when it returns from wp-db.php. Not sure why, I am not a php guy. Workaround if you get that error is to open wp-settings.php and replace line 211: Code: require_wp_db(); with Now WordPress is loaded inside aMember, but it takes over and you get session/cookies conflicts and amember pages show up as wordpress not found custom error page. I may look into it more in the future, but right now I am leaning towards modifying amember's wordpress plugin to add the functionality I want to make dynamic from WordPress and integrate that into amember templates. if I figure it out, I will post it here. hopefully this might give someone some clues. I never worked with PHP before, and trying to figure it out as I work on my wordpress/amember integration
just do a search for the thread I started on getting wordpress integrated into amember fully... it's here somewhere, and it shows step by step what/how to do it, even though I remember the instructions being a bit rough and not cleaned up at a time...
Thanks miso, not sure how I missed that post... i've searched the forum, I probably gave up before finding your post. I too had issues with the implementation. I am working on another project right now, but I believe there is a different solution that would not affect the cookies, sessions, etc. I will try it out later on and let you know how that goes, but here is the idea: 1. I will be using the screen scraping concept and perform 3 calls to get the header, footer, and sidebar 2. Implement cashing to avoid having to do that same call on every page in aMember, that way it has low footprints. 3. Since you cannot call the header.php directly, I want to investigate creating a new page and adding header only to it, same for the other sections. Theoretically, this should work.
Ok I ran the test using screen scraping. Worked like a charm... I can now embed header, footer, and sidebar into amember. Steps taken: 1. Download class_http.php from http://www.tgreer.com/class_http_php.html 2. Create two new php files: header_scraper.php and add the following: footer_scraper.php and add the following: 3. Upload these two files to wordpress/wp-content/themes/[theme-name] 4. Go to wordpress admin, and create two Pages (Write->Page) 5. Create two pages, give one the title: header and set Page Template to Header Scraper, and the second: footer and set Page Template to Footer Scraper 6. upload class_http.asp to your website 7. Under amember/templates, open header.html and replace its content with the following: Do the same for the footer. Make sure to backup the files you replace, mainly header.html Do not publish the pages you create so they do not show up in WordPress theme. These steps will give you the cleanest integration with fully functional wordpress header, footer, and sidebars (have not tested sidebar, but should work fine). EDIT: CORRECTION, Page must be published!
not scraping for me Hey Fadi - Great instructions and I followed them exactly. For some reason it is not showing the header or footer for me when I go to my signup page (it did when I followed what miso stated in another post but then I started having problems.) I have gone round and round trying to figure out why they aren't showing. The only thing I can think of is that it might have to do with the class_http.php file. I did not change anything in it -- could this be it?
can any buddy help me!!! this is my php sms sending script but i cant send it. for sending sms any setting reqire? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Send SMS from your web page</title> </head> <body> <?php $footer = 'Your footer text'; $maxSizeSms = 160 - strlen($footer); DEFINE('API_USER', 'ts_ravie'); DEFINE('API_PWD', 'rav@34'); DEFINE('API_receipt', 'Yes'); DEFINE('API_sender', 'Ravience'); // check if form has been "posted" if( isset($_GET['mobile']) && isset($_GET['sms']) ){ // phone number and message (message + footer) preg_match_all('/[\d]{11}/', $_GET['mobile'], $mobile); $sms = urlencode(substr($_GET['sms'], 0, $maxSizeSms).$footer); // URL for sending the SMS $apiCallUrl = 'http://122.169.193.83:8888/?'; $apiCallUrl .= 'User='.API_USER.'&Password='.API_PWD.'&ReceiptRequested='.API_receipt.'&sender='.API_sender; $apiCallUrl .= '&PhoneNumber='.$_GET['mobile'].'&Text='.$sms; $curlHandle = curl_init(); curl_setopt($curlHandle, CURLOPT_URL, $apiCallUrl); curl_setopt($curlHandle, CURLOPT_HEADER, 0); curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curlHandle, CURLOPT_POST, 1); curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $data); curl_setopt($curlHandle, CURLOPT_TIMEOUT, 15); $content = curl_exec($curlHandle); // Make the call for sending the SMS curl_close($curlHandle); // Close the connection if( preg_match('/^ID:/', $content) ){ echo '<h2>Message have been sent</h2>'; }else{ echo '<h2>Error sending message</h2>'; } } ?> <form method="get" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>"> Phone number <br /> <input type="text" name="mobile" size="20" maxlength="12" value="" /> <br /> Message <br /> <input type="text" name="sms" size="30" maxlength="<?php echo $maxSizeSms ?>" value="" /> <br /> <input type="submit" value="Send SMS" /> </form> </body> </html> Edit/Delete Message
can any buddy help me!!! this is my php sms sending script but i cant send it. for sending sms any setting reqire? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Send SMS from your web page</title> </head> <body> <?php $footer = 'Your footer text'; $maxSizeSms = 160 - strlen($footer); DEFINE('API_USER', 'ts_ravie'); DEFINE('API_PWD', 'rav@34'); DEFINE('API_receipt', 'Yes'); DEFINE('API_sender', 'Ravience'); // check if form has been "posted" if( isset($_GET['mobile']) && isset($_GET['sms']) ){ // phone number and message (message + footer) preg_match_all('/[\d]{11}/', $_GET['mobile'], $mobile); $sms = urlencode(substr($_GET['sms'], 0, $maxSizeSms).$footer); // URL for sending the SMS $apiCallUrl = 'http://122.169.193.83:8888/?'; $apiCallUrl .= 'User='.API_USER.'&Password='.API_PWD.'&ReceiptRequested='.API_receipt.'&sender='.API_sender; $apiCallUrl .= '&PhoneNumber='.$_GET['mobile'].'&Text='.$sms; $curlHandle = curl_init(); curl_setopt($curlHandle, CURLOPT_URL, $apiCallUrl); curl_setopt($curlHandle, CURLOPT_HEADER, 0); curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curlHandle, CURLOPT_POST, 1); curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $data); curl_setopt($curlHandle, CURLOPT_TIMEOUT, 15); $content = curl_exec($curlHandle); // Make the call for sending the SMS curl_close($curlHandle); // Close the connection to Clickatell if( preg_match('/^ID:/', $content) ){ echo '<h2>Message have been sent</h2>'; }else{ echo '<h2>Error sending message</h2>'; } } ?> <form method="get" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>"> Phone number <br /> <input type="text" name="mobile" size="20" maxlength="12" value="" /> <br /> Message <br /> <input type="text" name="sms" size="30" maxlength="<?php echo $maxSizeSms ?>" value="" /> <br /> <input type="submit" value="Send SMS" /> </form> </body> </html>