public function SaveMappings() { // Each XProfile field will have a select box selection assigned to it. // Save this selection. global $wpdb; $xprofile_table_name = $wpdb->prefix . 'bp_xprofile_fields'; $fields = $wpdb->get_results("SELECT name,type FROM {$xprofile_table_name} WHERE type != 'option'", ARRAY_A); foreach ($fields as $field) { // Encode the name of the field $selectName = AC_EncodeUserOptionName(WP88_BP_XPROFILE_FIELD_MAPPING, $field['name']); // Now dereference the selection $selection = $_POST[$selectName]; // Save the selection update_option($selectName, $selection); } }
public function SaveMappings() { // Each Cimy field will have a select box selection assigned to it. // Save this selection. global $wpdb; $cimy_table_name = $wpdb->prefix . 'cimy_uef_fields'; $sql = "SELECT NAME,TYPE FROM {$cimy_table_name}"; $fields = $wpdb->get_results($sql, ARRAY_A); foreach ($fields as $field) { // Encode the name of the field $selectName = AC_EncodeUserOptionName(WP88_CIMY_FIELD_MAPPING, $field['NAME']); // Now dereference the selection $selection = $_POST[$selectName]; // Save the selection update_option($selectName, $selection); } }
$output = ''; // NOTE: This just takes the FIRST selected list! Multiple selected lists // will just not work. $list = $listArray[0]; // Strip out the searchable tag $list = substr_replace($list, '', 0, strlen(WP88_SEARCHABLE_PREFIX)); $mergeVars = AC_FetchMailChimpMergeVars($api, $list); if (empty($mergeVars)) { print "<p><em><strong>Problem: </strong>AutoChimp could not retrieve your MailChimp Merge Variables. Make sure you have a selected mailing list.</em></p>"; } // // Start: Generate a table for WordPress mappings // global $wpUserDataArray; foreach ($wpUserDataArray as $userField) { $fieldNameTag = AC_EncodeUserOptionName(WP88_WORDPRESS_FIELD_MAPPING, $userField); $selectBox = AC_GenerateSelectBox($fieldNameTag, WP88_IGNORE_FIELD_TEXT, $mergeVars); $output .= '<tr class="alternate">' . PHP_EOL . '<td width="65%">' . $userField . '</td>' . PHP_EOL . '<td width="35%">' . $selectBox . '</td>' . PHP_EOL . '</tr>' . PHP_EOL; } // This static field used to belong to the BuddyPress Sync UI, but has since // been moved to the main UI. It's still represented by a DB value that makes // it look like it belongs to BuddyPress, so heads up. $selectBox = AC_GenerateSelectBox(WP88_MC_STATIC_FIELD, WP88_IGNORE_FIELD_TEXT, $mergeVars); $staticText = get_option(WP88_MC_STATIC_TEXT); $output .= '<tr class="alternate"><td width="65%">Static Text: <input type="text" name="static_select" value="' . $staticText . '"size="18" /></td><td width="30%">' . $selectBox . '</td></tr>'; $tableCode = AC_GenerateFieldMappingCode('WordPress', $output); print $tableCode; // // END: Generate a table for WordPress Mappings // // Show UI for any active AutoChimp plugins
public function SavePluginSettings() { // Save the option to turn on the plugin $publish = PublishEventsManager::GetPublishVarName(); AC_SetBooleanOption($publish, EVENTS_MANAGER_PUBLISH); // Save the option to publish each post type foreach ($this->m_PostTypes as $postType) { $varName = AC_EncodeUserOptionName(PublishEventsManager::GetPostTypeVarPrefix(), $postType); $optionName = AC_EncodeUserOptionName(EVENTS_MANAGER_POST_TYPE_PREFIX, $postType); AC_SetBooleanOption($varName, $optionName); } }
function AC_UpdateCampaignCategoryMappings() { // Need to query data in the BuddyPress extended profile table global $wpdb; // Get this site's categories $categories = get_categories('hide_empty=0&orderby=name'); // Data counter $counter = 1; $newIndex = 0; // Pull all of the mappings from the DB and update the option name. There // will be only one row for each category, so an index of 0 is safe. $options_table_name = $wpdb->prefix . 'options'; $sql = "SELECT option_name,option_value FROM {$options_table_name} WHERE option_name LIKE '" . WP88_CATEGORY_LIST_MAPPING . "%' ORDER BY option_name"; $fields = $wpdb->get_results($sql); if ($fields) { foreach ($fields as $field) { $data = AC_DecodeUserOptionName(WP88_CATEGORY_LIST_MAPPING, $field->option_name); $catInfo = explode('&', $data); // Set a suffix. Will be either "list", "group", or "template". The // original mapping didn't include "list". $suffix = '_list'; if (isset($catInfo[1])) { $suffix = "_{$catInfo['1']}"; } // Inefficient, but done once. This is necessary because AutoChimp // foolishly used to store the category name instead of slug in the // option_name. So, this code looks up the category by name and // finds the slug and writes that. foreach ($categories as $category) { // Look for a match. if (0 === strcmp($catInfo[0], $category->name)) { // Generate the new name and save it. $newName = AC_EncodeUserOptionName(WP88_CATEGORY_MAPPING_PREFIX, $newIndex . $suffix); update_option($newName, $field->option_value); AC_Log("Migrated {$field->option_value} from {$field->option_name} to {$newName}."); // Note that in 2.02 and earlier, there were three rows per // mapping. This needs to be translated into the new four // rows per mapping. So, when "_list" is encountered, just // take the time to write out "_category" too. if (0 === strcmp($suffix, '_list')) { $newName = AC_EncodeUserOptionName(WP88_CATEGORY_MAPPING_PREFIX, $newIndex . '_category'); update_option($newName, $category->slug); AC_Log("Migrated {$category->slug} from {$field->option_name} to {$newName}."); } } } // Update this every three passes. if (0 == $counter % 3) { $newIndex++; } $counter++; } } // Now delete the old rows. $sql = "DELETE FROM {$options_table_name} WHERE option_name LIKE '" . WP88_CATEGORY_LIST_MAPPING . "%'"; AC_Log("About to delete rows with this statement: {$sql}"); $numRows = $wpdb->query($sql); if (0 < $numRows) { AC_Log("Deleted {$numRows} from the {$options_table_name} table."); } else { AC_Log("No rows were found. Nothing deleted."); } }
public function SaveMappings() { // Need to query data in the BuddyPress extended profile table global $wpdb; $wishlist_table_name = $wpdb->prefix . 'wlm_options'; $sql = "SELECT option_name,option_value FROM {$wishlist_table_name} WHERE `option_name` LIKE 'CUSTOMREGFORM-%' ORDER BY `option_name` ASC"; $fields = $wpdb->get_results($sql, ARRAY_A); if (!$fields) { return; } foreach ($fields as $field) { $data = unserialize($field['option_value']); $formFields = explode(',', $data['fields']); foreach ($formFields as $formField) { if ($this->FilterUnusedFields($formField)) { continue; } // Encode the name of the field $selectName = AC_EncodeUserOptionName(AUTOCHIMP_WISHLIST_MEMBER_DB_FIELD_MAPPING, $formField); // Now dereference the selection $selection = $_POST[$selectName]; // Save the selection update_option($selectName, $selection); } } }
function AC_FetchMappedWordPressData($userID) { // User data array $dataArray = array(); // This global array holds the names of the WordPress user fields global $wpUserDataArray; // Get this user's data $user_info = get_userdata($userID); // Loop through each field that the user wants to sync and hunt down the user's // values for those fields and stick them into an array. foreach ($wpUserDataArray as $field) { // Figure out which MailChimp field to map to $optionName = AC_EncodeUserOptionName(WP88_WORDPRESS_FIELD_MAPPING, $field); $fieldData = get_option($optionName); // If the mapping is not set, then skip everything and go on to the next field if (0 !== strcmp($fieldData, WP88_IGNORE_FIELD_TEXT)) { // Now, get the user's data. Since the data is basically static, // this is just a collection of "if"s. if (0 === strcmp($field, 'Username')) { $value = $user_info->user_login; $dataArray[] = array('name' => $optionName, 'tag' => $fieldData, 'value' => $value); } elseif (0 === strcmp($field, 'Nickname')) { $value = $user_info->user_nicename; $dataArray[] = array('name' => $optionName, 'tag' => $fieldData, 'value' => $value); } elseif (0 === strcmp($field, 'Website')) { $value = $user_info->user_url; $dataArray[] = array('name' => $optionName, 'tag' => $fieldData, 'value' => $value); } elseif (0 === strcmp($field, 'Bio')) { $value = $user_info->user_description; $dataArray[] = array('name' => $optionName, 'tag' => $fieldData, 'value' => $value); } elseif (0 === strcmp($field, 'AIM')) { $value = $user_info->user_description; $dataArray[] = array('name' => $optionName, 'tag' => $fieldData, 'value' => $value); } elseif (0 === strcmp($field, 'Yahoo IM')) { $value = $user_info->user_description; $dataArray[] = array('name' => $optionName, 'tag' => $fieldData, 'value' => $value); } elseif (0 === strcmp($field, 'Jabber-Google Chat')) { $value = $user_info->user_description; $dataArray[] = array('name' => $optionName, 'tag' => $fieldData, 'value' => $value); } } } return $dataArray; }
echo $uiWidth; ?> px"> <h3 class='hndle'><span>Mail Campaigns from Posts</span></h3> <div class="inside"> <p><strong>Choose how you'd like to create campaigns from your post categories.</strong> <em>If you use a 'user template', be sure that the template's content section is called 'main' so that your post's content can be substituted in the template.</em></p> <p><fieldset style="margin-left: 20px;"><table> <tr><th>Category</th><th>Mailing List</th><th></th><th>Interest Group</th><th></th><th>User Template</th></tr> <?php // Fetch this site's categories $category_args = array('orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 0); $categories = get_categories($category_args); // Loop through each category and create a management row for it. foreach ($categories as $category) { $categoryOptionName = AC_EncodeUserOptionName(WP88_CATEGORY_LIST_MAPPING, $category->name); $categoryOptionGroupName = $categoryOptionName . WP88_CATEGORY_GROUP_SUFFIX; $categoryOptionTemplateName = $categoryOptionName . WP88_CATEGORY_TEMPLATE_SUFFIX; // Assemble the final Javascript $finalJavaScript = $javaScript . "switchInterestGroups('{$categoryOptionGroupName}',this.value,intGroupHash);\""; // Assemble the first select box's HTML print '<tr><td><em>' . $category->name . '</em> campaigns go to</td>' . PHP_EOL . '<td>'; $selectBox = AC_GenerateSelectBox($categoryOptionName, WP88_NO_MAILING_LIST, $listHash, $finalJavaScript); print $selectBox . '</td>' . PHP_EOL; // Start assembling the second select box print '<td>and group</td><td>'; $selectedlist = get_option($categoryOptionName); $selectBox = AC_GenerateSelectBox($categoryOptionGroupName, WP88_ANY_GROUP, $groupHash[$selectedlist]); print $selectBox . '</td>' . PHP_EOL; print '<td>using</td><td>'; $selectBox = AC_GenerateSelectBox($categoryOptionTemplateName, WP88_NO_TEMPLATE, $templatesHash);
public function SaveMappings() { // Select the fields from the options table (unserialized by WordPress) $fields = get_option(WP_MEMBERS_FIELDS); foreach ($fields as $field) { // Check that there's a string. Sometimes WP-Members will have // obnoxious empty arrays. if (0 == strlen($field[2])) { continue; } // Encode the name of the field $selectName = AC_EncodeUserOptionName(WP_MEMBERS_FIELD_DB_MAPPING, $field[2]); // Now dereference the selection $selection = $_POST[$selectName]; // Save the selection update_option($selectName, $selection); } }
function AC_SaveCampaignCategoryMappings() { // Fetch this site's categories $category_args = array('orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 0); $categories = get_categories($category_args); foreach ($categories as $category) { // Encode the name of the field $selectName = AC_EncodeUserOptionName(WP88_CATEGORY_LIST_MAPPING, $category->name); // Now dereference the selection $selection = $_POST[$selectName]; // Save the selection update_option($selectName, $selection); // Save off interest group selection now. Exact same principle. $groupSelectName = $selectName . WP88_CATEGORY_GROUP_SUFFIX; $groupSelection = $_POST[$groupSelectName]; update_option($groupSelectName, $groupSelection); // Same thing for templates $templateSelectName = $selectName . WP88_CATEGORY_TEMPLATE_SUFFIX; $templateSelection = $_POST[$templateSelectName]; update_option($templateSelectName, $templateSelection); } }