Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * Confirmation de lecture
- *
- */
- add_filter( 'rwmb_meta_boxes', 'confirmation_lecture_register_meta_boxes' );
- function confirmation_lecture_register_meta_boxes( $meta_boxes ) {
- $prefix = '';
- //global $post;
- //$post_id = $post->ID;
- //$ben = $GLOBALS['post']->ID;
- $ip_address = $_SERVER['SERVER_ADDR'];
- $meta_boxes[] = [
- 'title' => esc_html__( 'Confirmation de lecture', 'text-domain' ),
- 'id' => 'confirmation-lecture',
- 'fields' => [
- [
- 'id' => $prefix . 'signature',
- 'type' => 'text',
- 'name' => esc_html__( 'Signature', 'text-domain' ),
- 'required' => 1,
- ],
- [
- 'id' => $prefix . 'check_lecture',
- 'name' => esc_html__( '« Je confirme avoir lu le document »', 'text-domain' ),
- 'type' => 'checkbox',
- 'required' => 1,
- ],
- [
- 'id' => $prefix . 'testtest',
- 'type' => 'text',
- 'attributes' => array(
- 'value' => $post_id, // Here is the value who's not working
- )
- ],
- array(
- 'id' => $prefix . 'hidden_postid',
- 'type' => 'hidden',
- 'attributes' => array(
- 'value' => $post_id, // I tried both types text and hidden
- )
- ),
- array(
- 'id' => $prefix . 'ip_adrress',
- 'type' => 'hidden',
- 'attributes' => array(
- 'value' => $ip_address, // this value works well
- )
- ),
- array(
- 'id' => 'date_signature',
- 'type' => 'hidden',
- 'attributes' => array(
- 'value' => date('d/m/Y'), // this value works well
- )
- ),
- ],
- 'validation' => array(
- 'messages' => array(
- 'signature' => array(
- 'required' => 'Vous devez signer.',
- ),
- 'check_lecture' => array(
- 'required' => 'Vous devez confirmer la lecture.',
- ),
- ),
- ),
- ];
- return $meta_boxes;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement