|
docandtee
| Aha! Of course!
Thank you so much for your help Tareq. Amazing support!
Work perfectly now – and am now able to create my own templates!
Hopefully this will be of use to others out there.
Cheers and many thanks.
D
|
|
docandtee
| Hey Tareq
Thanks for your help on this. Still not getting this to work.
Here’s what I’ve got in my functions:
function delete_gallery_image() {
global $userdata;
$nonce = $_REQUEST['_wpnonce'];
if ( !wp_verify_nonce( $nonce, 'wpuf_del' ) ) {
die( "Security check" );
}
//check, if the requested user is the post author
$maybe_delete = get_post( $_REQUEST['pid'] );
if ( ($maybe_delete->post_author == $userdata->ID) ||
current_user_can( 'delete_others_pages' ) ) {
wp_delete_post( $_REQUEST['pid'] );
//redirect
$redirect = add_query_arg( array('msg' => 'deleted'),
get_permalink() );
wp_redirect( $redirect );
} else {
echo '<div class="error">' . __( 'You are not the
post author. Cheeting huh!', 'wpuf' ) . '</div>';
}
}
And here’s my posts query in my template file:
<?php global $current_user; get_currentuserinfo(); $user_id = get_current_user_id();
if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] ==
"del" ) {
$this->delete_gallery_image();
}
$homequery = new WP_Query( array( 'author' => $user_id, 'post_type' => 'artistimage', 'showposts' => '50') ); ?>
<?php while ( $homequery->have_posts() ) : $homequery->the_post(); ?>
<img src="<?php $image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,'blog-feature-sml', true);
echo $image_url[0]; ?>" alt="<?php the_title(); ?>" />
<?php $del_url = add_query_arg( array('action' => 'del', 'pid' => $post->ID) );?>
<a href="<?php echo wp_nonce_url( $del_url, 'wpuf_del' ) ?>" onclick="return confirm('Are you sure to delete?');"><?php _e( 'Delete', 'wpuf' ); ?></a>
<?php endwhile; wp_reset_postdata(); ?>
Can you see where I’m going wrong with this? It’s driving me slightly nuts!
Many thanks
D
|
|
docandtee
| Hi Tareq
Did you have a chance to look at my code?
Still unsure as to what I need to add to my functions file to get this delete function to work.
Would be really useful.
Many thanks
D
|
|
docandtee
| Hi Tareq
Here’s the template code:
http://pastebin.com/34jAnKbm
It’s a bit over complicated I know – but it’s an overly complicated project!
Let me know what you think I should add to my functions file.
Many thanks
D
|
|
docandtee
| Hi Tareq
Thanks for getting back to me.
I’m still struggling with this.
I’ve added this to my functions file but still not able to delete posts from the front end.
function delete_post() {
global $userdata;
$nonce = $_REQUEST['_wpnonce'];
if ( !wp_verify_nonce( $nonce, 'wpuf_del' ) ) {
die( "Security check" );
}
//check, if the requested user is the post author
$maybe_delete = get_post( $_REQUEST['pid'] );
if ( ($maybe_delete->post_author == $userdata->ID) || current_user_can( 'delete_others_pages' ) ) {
wp_delete_post( $_REQUEST['pid'] );
//redirect
$redirect = add_query_arg( array('msg' => 'deleted'), get_permalink() );
wp_redirect( $redirect );
} else {
echo '<div class="error">' . __( 'You are not the post author. Cheeting huh!', 'wpuf' ) . '</div>';
}
}
}
Am I missing anything else?
Many thanks
D
|
November 7, 2013 at 4:26 pm in reply to:
Dashboard template 9829 |
docandtee
| Thanks Tareq
Would be great to be able to edit or create your won templates for this.
Maybe something that could be added in the future?
Cheers
D
|
September 16, 2013 at 10:33 pm in reply to:
Custom Post Type order 8232 |
docandtee
| Anyone got any ideas on this? I know WordPress supports ordering by ‘menu_order’ but no idea how I would get this to work.
The only other method I can think of would be to order by a custom field but this could get messy if the author has lots of posts.
Thanks
D
|
September 11, 2013 at 3:59 pm in reply to:
Date field output 8019 |
docandtee
| Hi Tareq
Thanks for the reply.
I couldn’t get your code to work unfortunately. I did manage to get it working with the code below. But the thing that got rid of the weird 1970 date was to change the date format to yy-mm-dd. Does my code below look ok to you?
<?php $from_date = get_post_meta($post->ID, 'from_date', true);?>
<?php $fixed_from_date = strtotime($from_date); ?>
<!-- Display Date -->
day: <?php echo date('j' , $fixed_from_date) ; ?>
month: <?php echo date('n' , $fixed_from_date) ; ?>
year: <?php echo date('Y' , $fixed_from_date) ; ?>
<?php $until_date = get_post_meta($post->ID, 'until_date', true);?>
<?php $fixed_until_date = strtotime($until_date); ?>
<!-- Display Date -->
day: <?php echo date('j' , $fixed_until_date) ; ?>
month: <?php echo date('n' , $fixed_until_date) ; ?>
year: <?php echo date('Y' , $fixed_until_date) ; ?>
|
September 10, 2013 at 8:25 pm in reply to:
Date field output 7997 |
docandtee
| Hello again
I’ve made a little progress since my original question – but not quite solved it.
So I can output the dates how I want it but for some reason it only works for the first (from date). The second set of dates always come out as 1,1,1970 – which is weird. Can you only use one date picker on a post at a time? As I explained in my original post, I want to use two date picker fields to output a date range.
Here is the code I’m using in my template:
from day: <?php echo date( 'j', strtotime( get_post_meta( $post->ID, 'from_date', true ) ) ); ?>, from month: <?php echo date( 'n', strtotime( get_post_meta( $post->ID, 'from_date', true ) ) ); ?>, from year: <?php echo date( 'Y', strtotime( get_post_meta( $post->ID, 'from_date', true ) ) ); ?><br />
to day: <?php echo date( 'j', strtotime( get_post_meta( $post->ID, 'to_date', true ) ) ); ?>, to month: <?php echo date( 'n', strtotime( get_post_meta( $post->ID, 'to_date', true ) ) ); ?>, to year: <?php echo date( 'Y', strtotime( get_post_meta( $post->ID, 'to_date', true ) ) ); ?>
And this is what gets output:
from day: 9, from month: 12, from year: 2013
to day: 1, to month: 1, to year: 1970
Any ideas why the second date picker’s results are wrong?
Thanks
D
|
September 10, 2013 at 6:14 pm in reply to:
Custom Post type support in dashboard 7987 |
docandtee
| Hi Tareq
Yes, I went for similar approach in the end. I’ve set up multiple pages and a menu for each dashboard to navigate between views for different post types. Don’t know why I didn’t think of this before!
Thanks
D
|
August 29, 2013 at 10:47 pm in reply to:
Custom Post type support in dashboard 7639 |
docandtee
| Hi Tareq
Sorry I wasn’t clear enough in my original question.
What I actually want to do is break down the dashboard table into post type sections.
Like this:
Custom Post Type Video Posts:
video post 1 – edit
video post 2 – edit
Custom Post Type Gallery Posts:
gallery post 1 – edit
gallery post 2 – edit
etc etc.
At the moment it just lists all the different custom posts together in one long table so you can’t see what post type each post is.
Does that make sense?
Thanks
D
|
August 29, 2013 at 9:34 pm in reply to:
Custom Post type support in dashboard 7633 |
docandtee
| Hi Tareq
Sorry for re-opening this thread after a nearly two months!
I’ve decided that I really do need to separate out the custom post types in the dashboard.
In your last reply you mentioned that the only way to do this would be to create my own dashboard.
Can you point me in the direction of how I might go about doing this please?
Apart from this one niggle your plugin is spot on!
Cheers
D
|
|
docandtee
| Thanks Tareq
I’ll give that a go.
Thanks yet again for a swift response.
Cheers
D
|
|
docandtee
| Fantastic!
Thanks Tareq – that did the trick.
Many thanks for a prompt reply.
D
|
April 4, 2013 at 7:53 pm in reply to:
dashboard shows no posts 1801 |
docandtee
| Tareq that works!
Thank you! That’s been bugging me for ages. Must have missed that bit in the docs.
All seems fine now.
Thanks again.
D
|