Hello WordPress gurus! We have a client who is wanting to be able to restrict/grant access to pages on a WordPress site for certain groups in their Active Directory. Do you know of any plugins that already do this or a combination that can be used as a base to piece together functionality for this? I've worked with WordPress a few times before, but I mostly get .NET and Umbraco project requests from clients, so I'm not as familiar with what can be done in WordPress.
erpatton on "Active Directory - Grant/Restrict Access to Content"
jasperg on "Create a list of posts with topic heddings"
I hope this question makes sense.
I am designing a page for a second hand bookshop, It will be linked to in a weekly email newsletter containing that weeks books added to the store, so subscribers can keep updated on rare books that are available.
At the moment this is sent out as a pdf organised in broad categories. eg history, archaeology, antiquarian etc. With about 50-70 books on it.
The website I am building use a custom taxonomy to allow browsing of book categories.
For my weekly updates page I really need to have all books listed on one page with a heading for each category.
So using;
$args = array(
'date_query' => array(
array(
'column' => 'post_date_gmt',
'after' => 'Monday 1 week ago',
),
),
'posts_per_page' => -1,
'post_type' => 'product',
);
writing a loop that gets all books added after last monday if fine. But after reading http://wordpress.stackexchange.com/a/14309/53985 it seems that taxonomies are not a good way of listing posts like this. It seems I can do it but will have to;
- Get the top level taxonomies.
- for each taxonomy find all books added 'after' => 'Monday 1 week ago'
- If there are any new books in that taxonomy publish the title and the list of books.
- repeat for all taxonomies.
I am not sure exactly how to do this, and I am even less sure it is a good idea. Seeing as the list will go out to subscribers, it will probably be the most visited page on the site and peak the usage of the website as a whole each day the email is sent out (as everyone checks for new arrivals on the same day) and using complicated multiple loops may slow the page down???
So my question. Is this a good way of doing it? Will it be ok as there will only be ~50 posts to go through each time? or should I be looking at some other method?
Maybe I should add a custom meta field "Topic" to each book listing that is the same as each top level taxonomy and use this field to sort my book list? Would this be an improvement? Would that make it faster / easier? If I do this, and order the books by my Topic field. Would it be possible echo out the topic each time a new category starts as a title for each set of books, or would I have to echo the topic in each post, so people can see what category it belongs to?
Thank you for taking the time to read this. I know it is a rather complicated question, and I really appreciate any advice anyone can give me.
dangleraction on "Blank admin dashboard. Am I using wp_enqueue correctly on my child theme?"
Hello,
I have never had this problem before until I forced myself to use wp_enqueue_scripts. I think it's a really cool way of doing things, by the way. I'm a web designer and beginner at java programming.
My issue is just what the title says: Blank pages on my whole website, including the Dashboard. When the site does work, I see the blank page again whenever updating pages, configuring plugins, etc. It always crashes when "&_wpnonce=" is affixed the the end of my url.
When the parent theme is active, my Dashboard and all functions work fine, except my WP Admin bar is not showing on the front end. One problem at a time though.
My question is; What is the best way to arrange the wp_enqueue function to add specific scripts & stylesheets to specific pages?
I will share what my functions.php looks like in another comment, but for right now, can you tell me if this a good way to approach what I want to do?
<?php
if (!is_admin()) {
add_action( 'wp_enqueue_scripts', 'miosa_theme_scripts' );
function miosa_theme_scripts() {
if ( is_page_template('page-slider.php') ) {
wp_register_script('...');
wp_register_script('...');
wp_register_script('...');
wp_enqueue_script('modernizr');
wp_enqueue_script('slider-jquery');
wp_enqueue_script('slider-config');
}
elseif ( is_page_template('page-photo.php') ) {
wp_register_script('...') );
wp_register_script('...') );
wp_enqueue_script('isotope-jquery');
wp_enqueue_script('isotope-config');
}
}
}
That is a generalized version for my javascript. There is another one for my stylesheets and they all have a unique $handle
I am using the (!is_admin) condition because I thought these scripts were causing my WP Dashboard to be blank. It could be something else? I have no idea. But between this and my browser cache and server cache, this website development is taking a lot longer than I wanted it to. I would really appreciate to hear other peoples' advise because this is the first time I'm using the wp_enqueue_scripts constructor.
Thanks,
Rick
rechazame on "Whento use 'init' and when to use a function in functions.php?"
Let's say I want to disable users from viewing the dashboard.
I can add the following to functions.php
:
function hide_dashboard_init() {
if ( is_admin() && !current_user_can( 'manage_options' ) ) {
wp_redirect( home_url() );
exit;
}
}
add_action( 'init', 'hide_dashboard_init' );
But why not just add a regular function to functions.php
? Something like that:
function hide_dashboard() {
if ( is_admin() && !current_user_can( 'manage_options' ) ) {
wp_redirect( home_url() );
}
}
otti.steinhauer on "redirect to another wordpresspage when the Browser back-button is clicked"
Hello,
for my new plugin created a form. The user should fill the fields in the form in four steps, submit every part via button. But after the fourth step he must not go back to the steps of the form. Best it would be to redirect the user to the page where he started.
How can I do this?
Thanks
Ottilie
abdul wahab12 on "i want to block urls in comments."
please tell me some kind of php code for blocking curls in comments are. like if some one puts any url in comment an error comments that you cannot put urls of hyperlinks here.
edow on "Sidebar tag check sees only tags from first 9 posts"
Hi,
I use the following code in my category sidebar to check which tags are used in the category. It works, but only for the first 9 posts (the first page displays 9 posts.) How can I change this code so it also checks for the other posts in this category?
<?php
if (is_category()){
$cat = get_query_var('cat');
$yourcat = get_category ($cat);
}
$tag_IDs = array();
query_posts('category_name='.$yourcat->slug);
if (have_posts()) : while (have_posts()) : the_post();
$posttags = get_the_tags();
if ($posttags):
foreach($posttags as $tag) {
if (!in_array($tag->term_id , $tag_IDs)):
$tag_IDs[] = $tag->term_id;
$tag_names[$tag->term_id] = $tag->name;
$tag_slug[$tag->term_id] = $tag->slug;
endif;
}
endif;
endwhile; endif;
wp_reset_query();
$getTag = $_GET["tag"];
if ($getTag == '') {
$tag_showall = 'checked';
}
if (!empty($tag_IDs)){
echo '<h3>Aanbieders</h3>';
echo '<input type="radio" name="tag" value="" '.$tag_showall.'> Alles weergeven<br>';
}
foreach($tag_IDs as $tag_ID){
$checked = $tag_slug[$tag_ID];
echo '<input type="radio" name="tag" value="'.$checked.'"' ;
if((isset($_GET["tag"])) && $_GET["tag"] == $checked) {
echo ' checked="checked"';
}
echo '> '.$tag_names[$tag_ID].'<br>';
}
?>
Nico Hauser on "Wordpress Attachment Category Bulk Edit"
Hi,
I'm trying to assign attachment categories to my media files. With my theme I added a custom taxonomy called 'attachment_cat'. Now I want the bulk edit multiple files to assign this category(like in posts, pages or all custom post types).
I hope someone know's a solution, because it's a pain to add a category to every single media file.
Thanks
Tyratox
yogeshindia on "Stop Spam Message"
Hi..
I am getting lost of spam messages in my site http://www.hotel-booking-in.com.
Pls let know how to stop.
Regards
elsnare on "Pagination problem on custom wp_query sort order"
Hello!
Some info:
1. I'm using a custom build wp_query to display a list of custom posts with some custom post fields. Works great.
2. I'm using the following code to sort the posts ASC/DESC depending on custom fields. Simple url GET with custom keys and values. Also works fine.
<a href="<?php echo esc_attr( add_query_arg( 'order', 'city_desc' ) ); ?>"></a>
if (isset($_GET['order'])) {
$sort= $_GET['order'];
if($sort == 'city_desc'){
$args['order'] = 'DESC'; $args['meta_key'] = 'city';
}
The problem
When I enable pagination and sort the results - everything seems fine at first: the order is ok, the posts get split ect. But when I enter the second page of results something strange happens.
Let's say I have 3 posts and a custom field 'price':
POST A - 100
POST B - 200
POST C - 300
Posts per page is set to 2.
Pagination page #1 after sorting DESC I get:
POST C - 300
POST B - 200
But on page #2 I get:
POST C - 300
and that's it
So it seems there is a conflict between the pagination function which returns a given number of posts (1 in this example) on the 2nd page, but uses the sorting, resulting in a duplicate of POST C.
Here are the URL for those pages:
For sorted results:
list_page/?order=price_desc
For page #2
some_page/page/2/?order=price_desc%2F
I'm using a plugin to do the pagination.
Any thoughts? :)
mortonc on "Front end posting overwriting custom meta fields"
I've created this page in my theme which allows users to edit their posts. It changes the information which there are fields for in the page BUT it overwrites all the other custom meta fields which are not in the edit page. Any ideas of where I'm going wrong?
<?php /* Template Name: Edit Posts2 */
$query = new WP_Query(array('post_type' => 'customtype’, 'posts_per_page' =>'-1', 'post_status' => array('publish', 'pending', 'draft') ) );
if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post();
if(isset($_GET['post'])) {
if($_GET['post'] == $post->ID)
{
$current_post = $post->ID;
$title = get_the_title();
$content = get_the_content();
$custom_one = get_post_meta($current_post, 'custom_meta_1', true);
$custom_two = get_post_meta($current_post, 'custom_meta_2', true);
$custom_three = get_post_meta($current_post, 'custom_meta_3', true);
$custom_four = get_post_meta($current_post, 'custom_meta_4', true);
$custom_five = get_post_meta($current_post, 'custom_meta_5', true);
}
}
endwhile; endif;
wp_reset_query();
global $current_post;
$postTitleError = '';
if(isset($_POST['submitted']) && isset($_POST['post_nonce_field']) && wp_verify_nonce($_POST['post_nonce_field'], 'post_nonce')) {
if(trim($_POST['postTitle']) === '') {
$postTitleError = 'Please enter a title.';
$hasError = true;
} else {
$postTitle = trim($_POST['postTitle']);
}
$post_information = array(
'ID' => $current_post,
'post_title' => esc_attr(strip_tags($_POST['postTitle'])),
'post_content' => esc_attr(strip_tags($_POST['postContent'])),
'post-type' => 'customtype',
'post_status' => 'publish'
);
$post_id = wp_update_post($post_information);
if($post_id)
{
// Update Custom Meta
update_post_meta($post_id, 'custom_meta_1', esc_attr(strip_tags($_POST['customMetaOne'])));
update_post_meta($post_id, 'custom_meta_2', esc_attr(strip_tags($_POST['customMetaTwo'])));
update_post_meta($post_id, 'custom_meta_3', esc_attr(strip_tags($_POST['customMetaThree'])));
update_post_meta($post_id, 'custom_meta_4', esc_attr(strip_tags($_POST['customMetaFour'])));
update_post_meta($post_id, 'custom_meta_5', esc_attr(strip_tags($_POST['customMetaFive'])));
wp_redirect( home_url().'/?p=56' ); exit;
}
}
?>
<?php get_header(); ?>
<!-- #primary BEGIN -->
<div id="primary">
<form action="" id="primaryPostForm" method="POST">
<fieldset style="border:none;">
<label for="postTitle"><?php _e('Post\'s Title:', 'framework') ?></label>
<input type="text" name="postTitle" id="postTitle" value="<?php echo $title; ?>" class="required" />
</fieldset>
<?php if($postTitleError != '') { ?>
<span class="error"><?php echo $postTitleError; ?></span>
<div class="clearfix"></div>
<?php } ?>
<fieldset style="border:none;">
<label for="customMetaFour"><?php _e(‘Custom 4:’, 'framework') ?></label>
<input type="text" name="customMetaFour" id="customMetaFour" value="<?php echo $custom_four; ?>" />
</fieldset>
<fieldset style="border:none;">
<label for="postContent"><?php _e('Post\'s Content:', 'framework') ?></label>
<textarea name="postContent" id="postContent" rows="8" cols="30"><?php echo $content; ?></textarea>
</fieldset>
<fieldset style="border:none;">
<label for="customMetaOne"><?php _e(‘Custom 1:’, 'framework') ?></label>
<input type="text" name="customMetaOne" id="customMetaOne" value="<?php echo $custom_one; ?>" />
</fieldset>
<fieldset style="border:none;">
<label for="customMetaTwo"><?php _e(‘Custom 2:’, 'framework') ?></label>
<input type="text" name="customMetaTwo" id="customMetaTwo" value="<?php echo $custom_two; ?>" />
</fieldset>
<fieldset style="border:none;">
<label for="customMetaThree"><?php _e(‘Custom 3:’, 'framework') ?></label>
<input type="text" name="customMetaThree" id="customMetaThree" value="<?php echo $custom_three; ?>" />
</fieldset>
<b> Booking Toggle:</b>
</br>
<fieldset style="border:none;">
<span class="toggle">
<input type="checkbox" name="customMetaFive" id="customMetaFive" value="checked" <?php if($custom_five=="checked"){echo "checked";} ?> />
<label for="customMetaFive" data-off="OFF" data-on="ON"></label>
</span>
</fieldset>
<fieldset style="border:none;">
<?php wp_nonce_field('post_nonce', 'post_nonce_field'); ?>
<input type="hidden" name="submitted" id="submitted" value="true" />
<button type="submit"><?php _e('Update Post', 'framework') ?></button>
</fieldset>
</form>
</div><!-- #primary END -->
<?php get_footer(); ?>
HannibalBector on "Correct way to escape custom text area (while allowing urls)."
Hello there!
I'm developing my first WordPress theme and I have a helluva good time figuring things out. But I'm bit stumped on this seemingly simple problem!
- Let's say I have a text area in the customizer.
- I have sanitized the input using wp_kses_post and force_balance_tags.
Now I want to escape the output BUT I want to allow anyone using my theme to add links <a href="#">Link</a>
to this text area. Esc_html, esc_atr or any of the other escapes won't allow this. Sanitize_text_field won't allow this either. So what's the correct way to handle this? Am I missing something? Or should I forget about escaping /sanitization output?
BTW regarding wp_kses_post on output:
Note that the kses system can be resource-intensive, and should therefore not be run as an output sanitization filter directly, but as a filter to data after it has been input and processed, before it is saved in the database. WordPress runs kses on the pre_comment_content filter, for example, to filter the HTML before saving the comment.
http://codex.wordpress.org/Data_Validation#Output_Sanitization
Any help/thoughts will be appreciated! Thank you!
Best regards,
Michael
Kolsyra on "Add a specific post category to a specific page"
Hi,
I am pretty new to code php but after a few hours of google searching I
found that I could use this code to have a page pick up posts for a specific category:
if( is_page( 'kolsyra' ) {
query_posts( array( 'category_name' => 'kolsyra' ) );
}
just before the loop in the page.php file but I don't get it to work.
any help on this would be much appriciated.
I have tried to put the code within its own <?php and ?>
tags just above the loop and inside those tags for the loop itself just before the loop starts.
/Kolsyra
romeo1999 on "I want to add. Make users to upload photos"
Hello
I want to do the photo sharing site
http://wptit.com/portfolio/imgar-an-imgur-wordpress-theme
An example of this almost
A visitor comes to the site to download the image to the site
The Boktabh title, description and then loads the image to the site
She does not appear until after the approval of the Director on those pictures
Is there help
sakicmilan on "one of menu item right align"
hi, i want to last link in menu appear net to right margin lik
!link1 link2 link3 link4!
corpclik on "WooCommerce help"
First time posting a question.
I have a woo commerce store and on the category page, i would like to just show an attribute (model-number) instead of the product title.
I found in the archive-product.php where it creates the product loop for the category.
but can't find where to edit this to modify the title.
Can you please point me in the right direction or suggest some code?
Thanks in advance,
Mike
mayonis on "Random Error 500 When Using "upload_dir" Filter"
Hi,
I get random error 500 and error 404 when I use upload_dir as below:
add_filter('upload_dir', 'lean_upload_dir');
function lean_upload_dir( $upload ){
$upload['url'] = '/files';
$upload['baseurl'] = '/files';
return $upload;
}
See the issue here:
http://passionindesign.com/2014/05/15/安静/
Mostly, everything is working fine when you first visit the link.
And then every time you refresh the page, the photos are randomly broken with error 500 or 404. (Please try refresh the page a few times and you will see different images are broken everytime you refresh)
----------
These information might be helpful:
My WordPress installed on a shared hosting, with virtual memory 512mb
I think my host provider added this line in my .htacces: "suPHP_ConfigPath /home/my_root_folder/public_html"
in "my_root_folder", there is a php.ini (memory_limit = 256M)
serviceweb on "Custom registration form"
Hello, i've create this custom register form
<!-- Row for main content area -->
<div id="content" class="left eight columns" role="main">
<div class="post-box">
<?php get_template_part('/includes/content', 'page'); ?>
<div class="wrapper">
<?php
$err = '';
$success = '';
global $wpdb, $PasswordHash, $current_user, $user_ID;
if(isset($_POST['task']) && $_POST['task'] == 'register' ) {
$pwd1 = $wpdb->escape(trim($_POST['pwd1']));
$pwd2 = $wpdb->escape(trim($_POST['pwd2']));
$first_name = $wpdb->escape(trim($_POST['first_name']));
$last_name = $wpdb->escape(trim($_POST['last_name']));
$email = $wpdb->escape(trim($_POST['email']));
$username = $wpdb->escape(trim($_POST['username']));
if( $email == "" || $pwd1 == "" || $pwd2 == "" || $username == "" || $first_name == "" || $last_name == "") {
$err = 'Devi compilare tutti i campi obbligatori';
} else if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$err = 'Indirizzo email non valido.';
} else if(email_exists($email) ) {
$err = 'Indirizzo email già registrato.';
} else if($pwd1 <> $pwd2 ){
$err = 'Le password non corrispondono.';
} else {
$user_id = wp_insert_user( array ('first_name' => apply_filters('pre_user_first_name', $first_name), 'last_name' => apply_filters('pre_user_last_name', $last_name), 'user_pass' => apply_filters('pre_user_user_pass', $pwd1), 'user_login' => apply_filters('pre_user_user_login', $username), 'user_email' => apply_filters('pre_user_user_email', $email), 'role' => 'subscriber' ) );
if( is_wp_error($user_id) ) {
$err = 'Errore in fase di registrazione';
} else {
do_action('user_register', $user_id);
$success = 'You\'re successfully register';
wp_set_current_user( $user_ID, $current_user );
do_action('set_current_user');
$redirect_to = site_url('www.google.it');
wp_safe_redirect($redirect_to);
}
}
}
?>
<!--display error/success message-->
<div id="message">
<?php
if(! empty($err) ) :
echo '<p class="error">'.$err.'</p>';
endif;
?>
<?php
if(! empty($success) ) :
echo '<p class="error">'.$success.'</p>';
endif;
?>
</div>
<form method="post">
<h3>Registrati al Portale AlpeAdria</h3>
<div class="customregistrazione">
<label class="customregistrazione">Cognome*</label>
<input type="text" value="" name="last_name" id="last_name" style="width: 50%;" />
<label >Nome*</label>
<input type="text" value="" name="first_name" id="first_name" style="width: 50%;" />
<label>Email*</label>
<input type="text" value="" name="email" id="email" style="width: 50%;" />
<label>Username*</label>
<input type="text" value="" name="username" id="username" style="width: 50%;" />
<label>Password*</label>
<input type="password" value="" name="pwd1" id="pwd1" style="width: 50%;" />
<label>Reinserisci Password*</label>
<input type="password" value="" name="pwd2" id="pwd2" style="width: 50%;" />
</div>
<div class="alignleft"><p><?php if($sucess != "") { echo $sucess; } ?> <?php if($err != "") { echo $err; } ?></p></div>
<div>Compilando il seguente form di registrazione il cliente accetta quanto previsto nel disclaimer</div>
<button type="submit" name="btnregister" class="button" >Registrati</button>
<input type="hidden" name="task" value="register" />
</form>
</div>
</div><!-- End Content row -->
<?php get_sidebar( 'right' ); ?>
<?php get_footer();?>
And i want that the user redirect when the registration is ok. Now when visitor make a registration have the succesful message and continue see the form. I like automathic redirect registration to define page http://www.mysite.it/page. Whit my code the form function but not the redirect.
Also i like send an email to subscriber user with details
I try to add this but not function email ($email, "Registrazione OK", "Complimenti registrazione effettuata con successo", "From: email@redacted.com");
Where wrong? How can i resolve?
Thank's
Joontje48 on "PHP file_exists function won't work"
I have a WordPress website (still running locally) with different pages. I want each page to display its own unique header image (using the page name as image name), and am able to get that part working smoothly. But, when no header image is available (yet) for that specific page, I want to display a placeholder image. To do this, I use the file_exists function. It doesn't work, however. I use this code (note: this is a simplified/altered version. I don't bother you with the full code since I don't even get this simple code to work).
<img src="<?php
if (file_exists('/images/headers/home.jpg')) {
echo '/wp-content/themes/theme/images/headers/home.jpg';
}
else {
echo '/wp-content/themes/theme/images/headers/placeholder.jpg';
}
?>" />
The problem is: even though home.jpg exists, it keeps showing me the placeholder.jpg.
I already tried following file paths:
- Full link
- /wp-content/themes/theme/images/headers/home.jpg
- /images/headers/home.jpg
- home.jpg
Kolsyra on "PW Protected page don't ask for PW when..."
Hi,
I have added this code:
add_action( 'wp', 'post_pw_sess_expire' );
function post_pw_sess_expire() {
if ( isset( $_COOKIE['wp-postpass_' . COOKIEHASH] ) )
// Setting a time of 0 in setcookie() forces the cookie to expire with the session
setcookie('wp-postpass_' . COOKIEHASH, '', 0, COOKIEPATH);
}
into my functions.php and i t works fine when I click another page and then click the protected page again but if I use the back arrow in my browser it does not ask for the password again.
Can this be achived in any way?
/Kolsyra