Resources

My Agape try

Your Agape try


Support Forum

You must be logged in to post Login Register

Search 
Search Forums:


 




$_POST['post_ID'] not set

UserPost

11:58 am
December 3, 2010


lancehudson

Member

posts 9

1

In your commit 315926 /role-scoper/trunk/admin/filters-admin-save_rs.php, you use to global _POST['post_id']. I'm not sure how you do what you need to without it, but when I call wp_update_post( ) from ajax I get the notice that post_id isn't set. It isn't and isn't required by WordPress, if I have to I will set it, and will probably do it as a work around.

Full Backtrace:

( ! ) Notice: Undefined index: post_ID in \wordpress\wp-content\plugins\role-scoper\admin\filters-admin-save_rs.php on line 428
Call Stack
# Time Memory Function Location
1 0.0114 1029472 {main}( ) ..\admin-ajax.php:0
2 0.5713 31519624 do_action( ) ..\admin-ajax.php:1531
3 0.5713 31520568 call_user_func_array ( ) ..\plugin.php:395
4 0.5714 31520584 fee::ajax_handler( ) ..\plugin.php:0
5 0.5756 31557488 wp_update_post( ) ..\fee.php:483
6 0.5761 31563248 wp_insert_post( ) ..\post.php:2444
7 0.5763 31566792 sanitize_post( ) ..\post.php:2159
8 0.5814 31830160 sanitize_post_field( ) ..\post.php:1385
9 0.5814 31830984 apply_filters( ) ..\post.php:1460
10 0.5815 31831816 call_user_func_array ( ) ..\plugin.php:166
11 0.5815 31831864 ScoperAdminFilters->flt_page_parent( ) ..\plugin.php:0
12 0.5818 31831864 scoper_flt_page_parent( ) ..\filters-admin_rs.php:274

do you need anything else from me?

12:08 pm
December 3, 2010


lancehudson

Member

posts 9

2

Update: I changed id to post_ID in my code, that fixes the initial problem.

But now I also get $_POST['post_type'] on \wordpress\wp-content\plugins\role-scoper\admin\filters-admin-save_rs.php on line 380.

Unfortunately, the page sending the ajax request doesn't know what type it is, at least not right now.

( ! ) Notice: Undefined index: post_type in \wordpress\wp-content\plugins\role-scoper\admin\filters-admin-save_rs.php on line 380
Call Stack
# Time Memory Function Location
1 0.0152 1029504 {main}( ) ..\admin-ajax.php:0
2 0.5379 31555848 do_action( ) ..\admin-ajax.php:1531
3 0.5379 31556728 call_user_func_array ( ) ..\plugin.php:395
4 0.5379 31556744 fee::ajax_handler( ) ..\plugin.php:0
5 0.5393 31557352 wp_update_post( ) ..\fee.php:483
6 0.5398 31563112 wp_insert_post( ) ..\post.php:2444
7 0.5400 31566664 sanitize_post( ) ..\post.php:2159
8 0.5400 31569776 sanitize_post_field( ) ..\post.php:1385
9 0.5400 31570568 apply_filters( ) ..\post.php:1460
10 0.5405 31571504 call_user_func_array ( ) ..\plugin.php:166
11 0.5405 31571552 ScoperAdminFilters->flt_post_status( ) ..\plugin.php:0
12 0.5445 31829736 scoper_flt_post_status( ) ..\filters-admin_rs.php:265

2:43 pm
December 3, 2010


Kevin

Admin

posts 2503

3

So you're saving a post but you don't know what the post_type is? Or is my post_status filter somehow firing inappropriately when no post save is happening?

2:46 pm
December 3, 2010


lancehudson

Member

posts 9

4

I'm saving a post in my plugin using ajax. post_type is not defined. its not needed without your plugin, and currently the client side script that doing the saving doesn't know what the type is.

2:52 pm
December 3, 2010


Kevin

Admin

posts 2503

5

Given WordPress standards, I think it's fair for me to assume a post_type will be provided. Even posting a nullstring post_type would get you through that RS filter; not sure if it would cause problems elsewhere though.

2:54 pm
December 3, 2010


Kevin

Admin

posts 2503

6

I'm not sure you necessarily need to formally register a post type. But at least provide a value to distinguish it from other types in the DB.

2:57 pm
December 3, 2010


lancehudson

Member

posts 9

7

I can and will, I guess I'm just saying that without your plug I don't have to. in my code I pass an array with all that stuff, and I used get_post_type to get it for that. It would be great if you could get that information from that array instead of from the post global.

Again not sure how you would be able to do that.


Thanks for your help.

3:02 pm
December 3, 2010


Kevin

Admin

posts 2503

8

The filter code in question, which hooks on pre_post_status, fires before storage of the post. I can double-check but I don't think the entire post array is passed to the column-specific pre_ filters, is it?

3:13 pm
December 3, 2010


lancehudson

Member

posts 9

9

I'm not sure.

But I will give my background info.

I'm in a ajax action, wp_ajax_feeeditor

I am updating a post.

$type = get_post_type($id);

                if ($type && current_user_can('edit_' . $type, $id)) {

                    $the_post = array(

                        'ID' => $id,

                        'post_content' => $_POST['content'],

                    );

                    $ret = wp_update_post($the_post);

                    if (!$ret) //ohh no

                        die('-3');

I only have to pass 3 things, id, type, and content to wp_update_post.


I don't know much about pre_post_status, looking now, if only for my education.


About the Agapetry forum

Currently Online:

19 Guests

Maximum Online: 150

Forums:

Groups: 2

Forums: 7

Topics: 1245

Posts: 5653

Members:

There are 1255 members

There are 1 guests


Kevin has made 2503 posts

Top Posters:

metal450 - 178

Ragnar - 108

YikYak - 70

whiteorb - 49

Daisy - 35

Administrator: Kevin | Moderators: Kevin