Renewal form outside of amember, how to pull database info

Discussion in 'Integration' started by unmortal, Nov 14, 2011.

  1. unmortal

    unmortal New Member

    Joined:
    Sep 10, 2006
    Messages:
    25
    I used to have an offline form pulling entries like name, street, email, along with several custom fields I made.
    Code:
    <input type="text" name="home_phone" value="{$member.data.homephone}">
    I now have the (offline) form outside of the aMember directory. Specifically it's now a RSformPRO/Joomla form. So my question is what do I need to add to the page to get that functionality back?
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
  3. unmortal

    unmortal New Member

    Joined:
    Sep 10, 2006
    Messages:
    25
    Thanks Alex. I've tried everything from putting the session_start in the form to adding it to Joomla's public_html\index.php. It just doesn't seem to work. Nothing gets displayed. Is there any other way to do this? Is it maybe possible to pull the Joomla user and then match it up with the aMember user and pull his details? Any help is greatly appreciated!
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    It does not work because Joomla set own handler for php sessions. So there is no way to access standart php session that is used by aMember.
    Modify Joomla plugin so it will transfer additional variables from user's profile into Joomla. Then in your form inside Joomla, use variables from Joomla's user profile.
  5. rsigcourses

    rsigcourses Member

    Joined:
    Mar 8, 2011
    Messages:
    46
    I've got a form on a wordpress page no clue if its different than Joomla but what I did was include the config file. aMember is in a different directory than Wordpress.

    Code:
    include('/home/xxxxxxxxx/public_html/members/config.inc.php');
    $user = $_SESSION['_amember_user'];
    
    Then i'm able to do things like
    Code:
    <input type="text" value="<? echo $user[name_f] ?>" name="first_name">
    
    No clue if that will help you or not.
  6. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    This will not help. Wordpress do not change php session handlers but Joomla do this.
  7. unmortal

    unmortal New Member

    Joined:
    Sep 10, 2006
    Messages:
    25
    SOLVED:
    Code:
    <?php
    defined('_JEXEC') or die;
    $jomuser = JFactory::getUser();
    ?>
    
    <?php
    $hostname = 'localhost';
    $username = 'USER';
    $password = 'PASSWORD';
    $dbconn = new PDO("mysql:host=$hostname;dbname=DATABASE", $username, $password);
    
    $login = $jomuser->username;
    $login = $dbconn->quote($login);
    $userInfo = $dbconn->query("SELECT login, email, city FROM amember_members WHERE login=$login")->fetch(PDO::FETCH_ASSOC);
    ?>
    
    <br> This is printed from aMember db:
    <input name="username" value="<?php echo $userInfo['login'];?>" />
    <br> This is printed from aMember db:
    <input name="city" value="<?php echo $userInfo['city'];?>" />
    <br> This is printed from Joomla db:
    <input name="jusername" value="<?php echo $jomuser->username;?>" />
    

Share This Page