Advertisement
Beee

acf shortcode

Sep 18th, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.37 KB | None | 0 0
  1. <?php
  2.     $attr = shortcode_atts(array(
  3.         'ad' => ''
  4.     ), $attributes);
  5.     $error      = false;
  6.  
  7.     if ( !isset($_GET['ad']) ) {
  8.         $post_id = 0;
  9.     } else {
  10.         $post_id = $_GET['ad'];
  11.     }
  12.     if ( current_user_can('manage_options') ) {
  13.         $post_status= 'publish';
  14.     } else {
  15.         $post_status= 'pending';
  16.     }
  17.  
  18.     if ( $attr['ad'] == 0 ) {
  19.         $post_id            = 'new_post';
  20.         $submit_button      = __('Submit profile', 'dvp');
  21.         $updated_message    = __('Your ad is successfully submitted. We will review it a.s.a.p.', 'dvp');
  22.         $post_status        = $post_status;
  23.     } else {
  24.         $post_id            = $attr['ad'];
  25.         $submit_button      = __('Update profile', 'dvp');
  26.         $updated_message    = __('Your ad is successfully updated. We will review it a.s.a.p.', 'dvp');
  27.         $post_status        = $post_status;
  28.     }
  29.  
  30.     // count posts for current user
  31.     // if posts > 1, create notice
  32.  
  33.     return acf_form(array(
  34.         'post_id'           => $post_id,
  35.         // 'post_title'        => true,
  36.         // 'post_content'      => true,
  37.         'submit_value'      => $submit_button,
  38.         'updated_message'   => $updated_message,
  39.         'new_post'          => array(
  40.             'post_type'         => 'escort',
  41.             'post_status'       => $post_status
  42.         )
  43.     ));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement