Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. public function cats_edit_form_shortcode($atts, $content = null) {
  2.  
  3. if ( is_user_logged_in() ) {
  4. // current user id
  5. $user_id = get_current_user_id();
  6. $group_id = isset($_REQUEST['form_id']) ? $_REQUEST['form_id'] : '';
  7. $post_id = isset($_REQUEST['post_id']) ? $_REQUEST['post_id'] : '';
  8. $post = get_post($post_id);
  9. $author_id = $post->post_author;
  10.  
  11. if ( $user_id == $author_id ) {
  12. $atts = shortcode_atts( array( 'group_id' => $group_id, ), $atts);
  13.  
  14. if ( isset($atts['group_id']) ) {
  15. $post_meta = get_post_meta($atts['group_id']);
  16.  
  17. if (isset($post_meta['form_settings'])) {
  18. $form_settings = unserialize($post_meta['form_settings'][0]);
  19. }
  20.  
  21. if ( 'form' == $form_settings['display'] ) {
  22. $redirect_after_submit_url = $form_settings['redirect_after_submit'];
  23. $form_settings_user = $form_settings['who-can-post'];
  24. $form_actions = $form_settings['custom_actions'];
  25. $this->process_shortcode_atts( $atts, $form_settings, $redirect_after_submit_url, $form_actions, $post_id );
  26.  
  27. } else {
  28. return;
  29. }
  30. } else {
  31. return;
  32. }
  33. } else {
  34. echo '<div style="background: #fff;border-left: 4px solid #fff;border-left-color: #dc3232;-webkit-box-shadow: 2px 2px 5px 0px rgba(204,204,204,0.55); -moz-box-shadow: 2px 2px 5px 0px rgba(204,204,204,0.55); box-shadow: 2px 2px 5px 0px rgba(204,204,204,0.55);"><p style="margin: 2.5em; padding: 2px;">Warning: You do not have permission to edit this page</p></div>';
  35. return;
  36. }
  37. } else {
  38. echo '<div style="background: #fff;border-left: 4px solid #fff;border-left-color: #dc3232;-webkit-box-shadow: 2px 2px 5px 0px rgba(204,204,204,0.55); -moz-box-shadow: 2px 2px 5px 0px rgba(204,204,204,0.55); box-shadow: 2px 2px 5px 0px rgba(204,204,204,0.55);"><p style="margin: 2.5em; padding: 2px;">Warning: Either you did not login or your account has no right to post from frontend. Please use the other account which can edit post to do that.</p></div>';
  39. wp_login_form();
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement