set post_status in front end posting

hi stephanie,

i have a form for front end posting, i have a post_status field as i want people to be able to ‘pause’ (set to draft behind the scenes their adverts), anyway, i have most of it working,

i use this:

 

add_filter('frm_setup_new_fields_vars', 'frm_add_private', 40, 2);
add_filter('frm_setup_edit_fields_vars', 'frm_add_private', 40, 2);
function frm_add_private($values, $field){
  if($values['post_field'] == 'post_status'){
    $values['options']['private'] = 'Private';
  }
return $values;
}

but, i was wondering if there is a way to 'remove' not add new options?  for instance when a user is creating the ad for the first time the status should only show 'pending review' until its been reviewed by an admin, then i will set some custom field to show its been approved by admin then when user edits ad in the future after approval they will get a fuller set of status (draft/publish).
i couldnt see a 'frm_remove'
thanks
Darren

You can use unset.
unset($values['optons']['publish']);

Thanks Stephanie,

oddly doesnt work, maybe you cant unset post_status:

 

add_filter('frm_setup_new_fields_vars', 'frm_remove_option', 20, 2);
function frm_remove_option($values, $field){
if($values['post_field'] == 'post_status'){
unset($values['optons']['draft']);
}
return $values;
}

thanks

Darren

This is only for new entries. Are you editing an entry?

Try making it fire later (change 20 to 30).
add_filter('frm_setup_new_fields_vars', 'frm_remove_option', 30, 2);

do you never sleep ;-)

I had it set to 40,2 originally, didnt work (just tried again wtih 30,2) still no joy.

add_filter('frm_setup_new_fields_vars', 'frm_remove_option', 30, 2);
function frm_remove_option($values, $field){
if($values['post_field'] == 'post_status'){
unset($values['optons']['draft']);
}
return $values;
}
add_filter('frm_setup_edit_fields_vars', 'frm_add_private', 20, 2);
function frm_add_private($values, $field){
if($values['post_field'] == 'post_status'){
$values['options']['publish'] = 'Publish';
}
return $values;
}

 

 

 

thanks

D

Haha! We have a new baby... I don't get to sleep.

The first example worked fine for me after correcting a typo. (options not optons).
unset($values['optons']['draft']);

congrats on the baby :-)

 

dont you hate typos!  working.... which is good, must look more closely next time

 

thanks again

Darren

Topic closed.