Last active
January 11, 2016 16:27
-
-
Save joomdonation/faa01daea9c6a4672ba9 to your computer and use it in GitHub Desktop.
Syncronize Membership Pro profile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function synscronize_data() | |
| { | |
| $db = JFactory::getDbo(); | |
| require_once JPATH_COMPONENT . '/table/subscriber.php'; | |
| $row = JTable::getInstance('Subscriber', 'OSMembershipTable'); | |
| $sql = 'SELECT id FROM #__osmembership_subscribers WHERE user_id > 0 AND (published >= 1 OR payment_method="os_offline") ORDER BY id'; | |
| $db->setQuery($sql); | |
| $subscriberIds = $db->loadColumn(); | |
| foreach ($subscriberIds as $subscriberId) | |
| { | |
| $row->load($subscriberId); | |
| $sql = "SELECT id FROM #__osmembership_subscribers WHERE is_profile=1 AND user_id = $row->user_id"; | |
| $db->setQuery($sql); | |
| $profileId = $db->loadResult(); | |
| if ($profileId && ($profileId != $row->id)) | |
| { | |
| if ($row->is_profile == 1 || ($row->profile_id != $profileId)) | |
| { | |
| $row->is_profile = 0; | |
| $row->profile_id = $profileId; | |
| $row->store(); | |
| } | |
| } | |
| elseif ($row->is_profile == 0) | |
| { | |
| $row->is_profile = 1; | |
| $row->store(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment