- This topic has 6 replies, 2 voices, and was last updated 3 years ago by .
-
Topic
-
OK, I give up. I need a point in the right direction here.
First: I very much love this plugin and all the extentinos. Every project I get to use this, I get a little more impressed. Well done! Now, on to my Issue…
I am attempting to use a custom attribute to control how exactly the meta data is saved. Specifically, I assign a attribute called
mod_lock
that I want to use from within therwmb_before_save_post
action. To make this work I need both the post_id and the $field array.Custom Attribute is defined like-a-so:
'fields' => array( array( 'name' => __('Favorite Monkey', 'monkey-monk'), 'id' => 'fav_monkey', 'type' => 'text', 'attributes' => array( 'mod_lock' => true, ), ), ),
Ultimately I would like to handle the savinging of the metadata something like:
function monkey_mod_save( $new, $old, $post_id, $field ) { $pre = ''; if(!empty($field['attributes']['mod_lock'])){ $pre = 'pending_'; } if($new !== $old){ $storage->update( $post_id, $pre.$field['id'], $new); } if( empty($new) ){ $storage->delete( $post_id, $pre.$field['id'] ); } }
But this is the ‘save’ function… so I focused on the pre_save action, however all I have access to there is the $post_id and of course the $_POST data… but none of the delicious $field attributes.
I need your help, Obi-Anh!
- The topic ‘Using Custom Attributes from rwmb_before_save_post action’ is closed to new replies.