Hi Chris,
I’m stuck again.
I’m trying to use your “showHideFieldsForUsers” plugin (my code is below) to implement a multi level membership scheme and I’ve come up against a bit of a snag.
Here’s the issue:
UPGRADE WORKS FINE
A member upgrades their membership level, and thanks to your plugin they are allowed to access additional fields in the database and they get added functionality.
They create some records with this additional functionality and all records that they have authored appear with all of the information fields available for them to modify.
PROBLEM ON DOWNGRADE
The problem comes in if that member decides to downgrade their membership and they lose access to those additional fields, even for records that already have data in those fields.
QUESTION
Can you think of a way to allow the now downgraded member to access (and modify) the now hidden fields in their records where fields already have data entered in them? Just not to be able to create any new records using those fields?
ALTERNATIVE
I guess that the alternative is that they’d have to delete the existing record and when recreating it, they just won’t be able to enter data into the now hidden fields.
THIS CREATES A DIFFERENT PROBLEM
Since they can’t see the data in the hidden fields, they won’t have any easy way to know when the record needs to be deleted and updated.
Thanks,
Jerry Kornbluth
<?php
// CAVEATS:
// - it is not currently possible to hide Separator fields.
// UPDATE THESE VALUES
$GLOBALS['BETA_USER_SKILL_FIELDS_SKILL_FIELD_NAME'] = 'allowedFolders';
// For each section, copy this block
$GLOBALS['BETA_USER_SKILL_FIELDS_CONFIG']['master_subscription_pages'] = array(
// user's skill values and lists of fields to hide
'entry_level' => array('__separator001__','__separator002__','paypal_payment_address', 'paypal_invoice_description', 'price_of_work','tm_offer_description','short_code','key_word'),
'silver' => array('__separator002__','tm_offer_description','short_code', 'key_word'),
'gold' => array('__separator002__','tm_offer_description','short_code', 'key_word'),
'platinum' => array()
);
// DON'T UPDATE ANYTHING BELOW THIS LINE
// register hooks
addFilter('edit_buttonsRight', 'beta_user_skill_fields_edit_filter', null, 3);
// add javascript to edit pages
function beta_user_skill_fields_edit_filter($html, $tablename, $record) {
global $CURRENT_USER;
$hiddenFields = @$GLOBALS['BETA_USER_SKILL_FIELDS_CONFIG'][$tablename][@$CURRENT_USER[$GLOBALS['BETA_USER_SKILL_FIELDS_SKILL_FIELD_NAME']]];
if (!$hiddenFields) { return $html; }
?>
<script>
$(function(){
<?php foreach($hiddenFields as $hiddenField): ?>
$('*[name="<?php echo $hiddenField; ?>"]').closest('TR').hide();
$('*[name^="<?php echo $hiddenField; ?>:"]').closest('TR').hide();
$('#<?php echo $hiddenField; ?>_iframe').closest('TR').hide();
<?php endforeach; ?>
});
</script>
<?php
return $html;
}
?>
The first CMS Builder reference book is now available on-line!
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php