fixed redirect field for 1 and 2 accessible option

This commit is contained in:
nikitasinelnikov
2017-03-24 18:26:05 +02:00
committed by GitHub
parent bfb6bc460a
commit 3fdd843073
+18 -9
View File
@@ -70,10 +70,10 @@
}
}
function um_category_access_fields_create( $term ) {
function um_category_access_fields_create( $term ){
global $ultimatemember;
echo '<div class="form-field term-access-wrap um-conditional-radio-group" data-cond1="2" data-cond1-show="term-roles-wrap" data-cond2="1" data-cond2-show="term-redirect-wrap">';
echo '<label>' . __('Content Availability','ultimatemember') . '</label>';
echo '<label><input type="radio" name="_um_accessible" value="0" checked /> '. __('Content accessible to Everyone','ultimatemember') . '</label>
@@ -88,20 +88,22 @@
echo '<label><input type="checkbox" name="_um_roles[]" value="' . $role_id . '" /> ' . $role . '</label>';
}
echo '<p class="description">' . __('This is applicable only if you restrict the content to logged-in users.','ultimatemember') . '</p>';
echo '<label>' . __('Content Restriction Redirect URL','ultimatemember') . '</label>';
echo '<input type="text" name="_um_redirect" id="_um_redirect" value="" />';
echo '<p class="description">' . __('Users who cannot see content will get redirected to that URL.','ultimatemember') . '</p>';
echo '</div>';
echo '<div class="form-field term-redirect-wrap">';
echo '<label>' . __('Content Restriction Redirect URL','ultimatemember') . '</label>';
echo '<input type="text" name="_um_redirect" id="_um_redirect" value="" />';
echo '<input type="text" name="_um_redirect2" id="_um_redirect2" value="" />';
echo '<p class="description">' . __('Users who cannot see content will get redirected to that URL.','ultimatemember') . '</p>';
echo '</div>';
}
function um_category_access_fields_edit( $term ) {
function um_category_access_fields_edit( $term ){
global $ultimatemember;
$termID = $term->term_id;
$termMeta = get_option( "category_$termID" );
$_um_accessible= (isset( $termMeta['_um_accessible'] ) )? $termMeta['_um_accessible'] : '';
@@ -127,18 +129,24 @@
}
echo '<label><input type="checkbox" name="_um_roles[]" value="' . $role_id . '" ' . $checked . ' /> ' . $role . '</label>&nbsp;&nbsp;';
}
echo '<p class="description">' . __('This is applicable only if you restrict the content to logged-in users.','ultimatemember') . '</p>';
echo "</td></tr>";
echo "<tr class='form-field form-required term-roles-wrap'>";
echo "<th scope='row'><label>" . __('Content Restriction Redirect URL','ultimatemember') . "</label></th>";
echo '<td>';
echo '<input type="text" name="_um_redirect" id="_um_redirect" value="' . $_um_redirect . '" />';
echo '<p class="description">' . __('Users who cannot see content will get redirected to that URL.','ultimatemember') . '</p>';
echo "</td></tr>";
echo "<tr class='form-field form-required term-redirect-wrap'>";
echo "<th scope='row'><label>" . __('Content Restriction Redirect URL','ultimatemember') . "</label></th>";
echo '<td>';
echo '<input type="text" name="_um_redirect" id="_um_redirect" value="' . $_um_redirect . '" />';
echo '<input type="text" name="_um_redirect2" id="_um_redirect2" value="' . $_um_redirect . '" />';
echo '<p class="description">' . __('Users who cannot see content will get redirected to that URL.','ultimatemember') . '</p>';
echo "</td></tr>";
}
function um_category_access_fields_save( $termID ){
if ( isset( $_POST['_um_accessible'] ) ) {
@@ -151,6 +159,7 @@
// get value and save it into the database - maybe you have to sanitize your values (urls, etc...)
$termMeta['_um_accessible'] = isset( $_POST['_um_accessible'] ) ? $_POST['_um_accessible'] : '';
$termMeta['_um_redirect'] = isset( $_POST['_um_redirect'] ) ? $_POST['_um_redirect'] : '';
$termMeta['_um_redirect2'] = isset( $_POST['_um_redirect2'] ) ? $_POST['_um_redirect2'] : '';
$termMeta['_um_roles'] = isset( $_POST['_um_roles'] ) ? $_POST['_um_roles'] : '';
update_option( "category_$termID", $termMeta );