Forum Replies Created

Viewing 15 Topics - 1 through 15 (of 19 total)
Author Posts
January 31, 2014 at 9:09 pm in reply to: Delete post action for custom template 14968
docandtee 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

January 31, 2014 at 5:58 pm in reply to: Delete post action for custom template 14955
docandtee 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

January 29, 2014 at 4:41 pm in reply to: Delete post action for custom template 14867
docandtee 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

January 23, 2014 at 6:19 pm in reply to: Delete post action for custom template 14721
docandtee 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

January 21, 2014 at 6:07 pm in reply to: Delete post action for custom template 14660
docandtee 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 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 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 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 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 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 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 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

June 26, 2013 at 2:53 pm in reply to: Custom Post taxonomy checkbox: checked? 5284
docandtee docandtee

Thanks Tareq
I’ll give that a go.
Thanks yet again for a swift response.

Cheers

D

June 26, 2013 at 12:10 pm in reply to: Registration form: images not showing in user profile 5277
docandtee 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 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

Viewing 15 Topics - 1 through 15 (of 19 total)