如何检查当前用户(ID)是否有帖子

时间:2015-05-11 10:47:53

标签: php wordpress-plugin wordpress

我有自定义模板。在其中我想检查,如果当前登录用户有自定义帖子名为(student_form)或不是如果帖子等于真我想将其重定向到某个页面其他明智我想向他/她显示我使用wp创建的表单前端用户。

我编写了以下代码,但如果用户有自定义帖子,则不会重定向到所需的页面。

     <?php 
     /*
     * Template Name: Form Page
     */
     get_header(); 

     global $post,$current_user;
     get_currentuserinfo();

     if ($post->post_author == $current_user->ID) {
     exit( wp_redirect(http://MYurl/dashboard/') );

     }
     else
     {
     echo do_shortcode('[wpuf_form id="414"]');
     }

     wp_reset_query();  // Restore global post data stomped by the_post().
     get_footer(); 
     ?>   

0 个答案:

没有答案
相关问题