سیدرضا بازیار 257 ارسال شده در دی 92 گزارش بازنشر ارسال شده در دی 92 من میخوام توی سایتم واسه کاربران (نویسندگان) محدودیت ایجاد کنم. به طوری که هر 24 ساعت فقط 30 تا مطلب رو ارسال کنن. بیش از 30 مطلب رو نتونن ارسال کننفقط مدیریت کل سایت بتونه بیشتر از 3 تا ارسال کنه نقل قول لینک به ارسال
Parsa 23463 ارسال شده در دی 92 گزارش بازنشر ارسال شده در دی 92 این افزونه را تست کنیدhttp://wordpress.org/plugins/bainternet-posts-creation-limits/این کد هم برای کمک به افزونه بالاadd_action( 'post_creation_limits_custom_checks', 'post_per_day_limit' );function post_per_day_limit( $type, $user_id ) { global $bapl,$wpdb; // safe check: Plugin installed? ! isset( $bapl ) AND _doing_it_wrong( __FUNCTION__, sprintf( 'You need to %sinstall the needed Plugin%s', '<a href="http://wordpress.org/extend/plugins/bainternet-posts-creation-limits/">', '</a>' ), 0 ); $time_in_days = 1; // 1 means in last day $count = $wpdb->get_var( $wpdb->prepare(" SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = %s AND post_author = %s AND post_date >= DATE_SUB(CURDATE(),INTERVAL %s DAY)", $type, $user_id, $time_in_days ) ); if ( 0 < $count ) $count = number_format( $count ); // here you can check since we have the $count ex: // limit for 2 posts a day if ( 5 < $count ) { // return limit reached message using the plugin class exit( $bapl->bapl_not_allowed( 'you can not posts more them two posts a day' ) ); } // else do nothing}عدد 5 تعداد محدودیت ارسال برای هر کاربر هست 3 نقل قول لینک به ارسال
سیدرضا بازیار 257 ارسال شده در دی 92 مالک گزارش بازنشر ارسال شده در دی 92 افزونه رو نصب کردم و کد رو توی استایل قرار دادمنقش کاربری رو هم معین کردماما افزونه جواب ندادالآن کاربر میتونه هر چی دلش خواست پست ارسال کنه نقل قول لینک به ارسال
Morteza 34190 ارسال شده در دی 92 گزارش بازنشر ارسال شده در دی 92 http://cleverness.org/2010/08/13/limit-number-of-posts-per-user-in-wordpress/ 3 نقل قول لینک به ارسال
سیدرضا بازیار 257 ارسال شده در دی 92 مالک گزارش بازنشر ارسال شده در دی 92 میشه یه توضیح فارسی هم بدید؟یا ترجمه اون رو توی انجمن بزارید نقل قول لینک به ارسال
Parsa 23463 ارسال شده در دی 92 گزارش بازنشر ارسال شده در دی 92 مترجم گوگلhttp://translate.google.com/ نقل قول لینک به ارسال
سیدرضا بازیار 257 ارسال شده در دی 92 مالک گزارش بازنشر ارسال شده در دی 92 با مترجم گوگل هم پیش رفتماما چیزی رو متوجه نشدم4 تا کد رو داده که فقط میدونم اولی رو کجا بزارماون 3 تا رو نمیدونم کجا بزارم نقل قول لینک به ارسال
Parsa 23463 ارسال شده در دی 92 گزارش بازنشر ارسال شده در دی 92 کد اول رو در فایل functions// limit number of posts per user// provided by cleverness.orgif ( !current_user_can('manage_options') ) { $default = 1; // default number of posts $count_posts = 0; global $wpdb; $poststable = $wpdb->prefix.'posts'; $postlimit = get_user_meta($current_user->id, 'postlimit', true); if ( $postlimit == '' ) $postlimit = $default; $query = "SELECT COUNT(*) FROM $poststable WHERE post_author = '$current_user->id' AND (post_status = 'pending' OR post_status = 'draft' OR post_status = 'publish' ) "; $count_posts = $wpdb->get_var($query); if ($count_posts >= $postlimit) { if ( $_SERVER['REQUEST_URI'] == '/wp-admin/post-new.php' ) Header("Location: index.php");//redirects to dashboard if ( is_admin() ){ $stylesheet = get_stylesheet_directory_uri() . '/css/limitposts.css'; wp_register_style('limitpost_admin_css', $stylesheet, false, '1', 'screen'); wp_enqueue_style('limitpost_admin_css'); } }}// add post limit option to profileadd_filter('user_contactmethods','hide_profile_fields',10,1);function hide_profile_fields( $contactmethods ) { if( current_user_can( 'manage_options' ) ) $contactmethods['postlimit'] = 'Post Limit'; return $contactmethods;}در پوشه پوسته پوشهای به نام css ایجاد و فایل limitposts.css ایجاد کنید. کد زیر را در آن قرار دهید#menu-posts .wp-first-item + li { display: none;} 2 نقل قول لینک به ارسال
سیدرضا بازیار 257 ارسال شده در دی 92 مالک گزارش بازنشر ارسال شده در دی 92 ممنونکجای این کد میتونم تعیین کنم که کاربر در هر ساعت بتونه 1 پست ارسال کنه؟ نقل قول لینک به ارسال
Parsa 23463 ارسال شده در دی 92 گزارش بازنشر ارسال شده در دی 92 کد مشکل داشتاین رو تست کنیدif ( !current_user_can('level_10') ) { $default = 1; // default number of posts $hour = 1; $count_posts = 0; global $wpdb,$current_user; $time = date('Y-m-d H:i:s', strtotime('-'.$hour.' hours')); $poststable = $wpdb->prefix.'posts'; $postlimit = get_user_meta($current_user->id, 'postlimit', true); if ( $postlimit == '' ) $postlimit = $default; $query = "SELECT COUNT(*) FROM $poststable WHERE post_date > '$time' post_author = '$current_user->id' AND (post_status = 'pending' OR post_status = 'draft' OR post_status = 'publish' ) "; $count_posts = $wpdb->get_var($query); if ($count_posts >= $postlimit) { if ( $_SERVER['REQUEST_URI'] == '/wp-admin/post-new.php' ) Header("Location: index.php");//redirects to dashboard if ( is_admin() ){ $stylesheet = get_stylesheet_directory_uri() . '/css/limitposts.css'; wp_register_style('limitpost_admin_css', $stylesheet, false, '1', 'screen'); wp_enqueue_style('limitpost_admin_css'); } }}مقدار default برای تعداد پستمقدار hour برای ساعت هست 2 نقل قول لینک به ارسال
سیدرضا بازیار 257 ارسال شده در دی 92 مالک گزارش بازنشر ارسال شده در دی 92 متاسفانه قالب من از دستورات وردپرس پیروی نمیکنهمثلا: بخش نظرات رو از وردپرس غیر فعال کردم، اما توی این قالب غیر فعال نشده و راحت میشه نظر گذاشتتا حالا همچین چیزی رو ندیده بودمبه نظر شما این کد رو کجای قالب بزارم تا بتونه ارسال پست رو محدود کنه؟آدرس سایت: http://www.balyan.ir/sms نقل قول لینک به ارسال
Parsa 23463 ارسال شده در دی 92 گزارش بازنشر ارسال شده در دی 92 کد برای پست هست نه نظرهاکد رو هم به functions.php پوسته اضافه و تست کنید 2 نقل قول لینک به ارسال
سیدرضا بازیار 257 ارسال شده در دی 92 مالک گزارش بازنشر ارسال شده در دی 92 کد مشکل داشتاین رو تست کنیدif ( !current_user_can('level_10') ) { $default = 1; // default number of posts$hour = 1; $count_posts = 0; global $wpdb,$current_user;$time = date('Y-m-d H:i:s', strtotime('-'.$hour.' hours')); $poststable = $wpdb->prefix.'posts'; $postlimit = get_user_meta($current_user->id, 'postlimit', true); if ( $postlimit == '' ) $postlimit = $default; $query = "SELECT COUNT(*) FROM $poststable WHERE post_date > '$time' post_author = '$current_user->id' AND (post_status = 'pending' OR post_status = 'draft' OR post_status = 'publish' ) "; $count_posts = $wpdb->get_var($query); if ($count_posts >= $postlimit) { if ( $_SERVER['REQUEST_URI'] == '/wp-admin/post-new.php' ) Header("Location: index.php");//redirects to dashboard if ( is_admin() ){ $stylesheet = get_stylesheet_directory_uri() . '/css/limitposts.css'; wp_register_style('limitpost_admin_css', $stylesheet, false, '1', 'screen'); wp_enqueue_style('limitpost_admin_css'); } }}مقدار default برای تعداد پستمقدار hour برای ساعت هستدقیقا عدد رو کجای اون بزارم؟مثلا میخوام بزارم هر ساعت 1 پست بتونه ارسال کنه نقل قول لینک به ارسال
سیدرضا بازیار 257 ارسال شده در دی 92 مالک گزارش بازنشر ارسال شده در دی 92 کد رو امتحان کردم. اما کار نمیکنهاصلا وردپرس همچین امکاناتی داره یا نه؟لطفا راهنمایی کنید نقل قول لینک به ارسال
Parsa 23463 ارسال شده در دی 92 گزارش بازنشر ارسال شده در دی 92 کد مشخصی نیستباید خودتون بنوسید 1 نقل قول لینک به ارسال
سیدرضا بازیار 257 ارسال شده در دی 92 مالک گزارش بازنشر ارسال شده در دی 92 اما من کد نویسی این بخش رو بلد نیستمیه برنامه نویس حرفه ای چقدر پول میگیره این کد رو برام بسازه؟ نقل قول لینک به ارسال
Parsa 23463 ارسال شده در دی 92 گزارش بازنشر ارسال شده در دی 92 تست کنیدadd_action("init","wpp_test_function");function wpp_test_function(){ global $wpdb,$pagenow; if (is_admin() && $pagenow=="post-new.php" && (! current_user_can('level_10')) ) { $default = 1; // default number of posts $hour = 1; $count_posts = 0; $time = date('Y-m-d H:i:s', strtotime('-'.$hour.' hours')); $poststable = $wpdb->prefix.'posts'; $userid = get_current_user_id(); if ( $postlimit == '' ) $postlimit = $default; $query = "SELECT COUNT(*) FROM $poststable WHERE post_date > '$time' AND post_author = $userid AND (post_status = 'pending' OR post_status = 'draft' OR post_status = 'publish' ) "; $count_posts = $wpdb->get_var($query); if ($count_posts >= $postlimit) { wp_redirect("edit.php"); //redirects to dashboard } }} 2 نقل قول لینک به ارسال
سیدرضا بازیار 257 ارسال شده در بهمن 92 مالک گزارش بازنشر ارسال شده در بهمن 92 تست کنیدadd_action("init","wpp_test_function");function wpp_test_function(){global $wpdb,$pagenow;if (is_admin() && $pagenow=="post-new.php" && (! current_user_can('level_10')) ) { $default = 1; // default number of posts $hour = 1; $count_posts = 0; $time = date('Y-m-d H:i:s', strtotime('-'.$hour.' hours')); $poststable = $wpdb->prefix.'posts'; $userid = get_current_user_id(); if ( $postlimit == '' ) $postlimit = $default; $query = "SELECT COUNT(*) FROM $poststable WHERE post_date > '$time' AND post_author = $userid AND (post_status = 'pending' OR post_status = 'draft' OR post_status = 'publish' ) "; $count_posts = $wpdb->get_var($query); if ($count_posts >= $postlimit) { wp_redirect("edit.php"); //redirects to dashboard }}}کد رو در فانکشن گذاشتم. اما باز هم جواب ندادفکر کنم کد درست باشه و دلیل کار نکردن کد این باشه که قالب اون بسیار پیچیده ساخته شده (خیلی از وب نویس های بزرگ از طراحی عجیب این قالب تعجب کردند... )post-new.php و edit.php در قالب وجود ندارهلطفا باز هم تلاش کنید تا این مشکل رفع بشه نقل قول لینک به ارسال
Parsa 23463 ارسال شده در بهمن 92 گزارش بازنشر ارسال شده در بهمن 92 کد رو من تست کردممشکل نداردpost-new.php و edit.php فایلهای وردپرس هستند نه پوسته 1 نقل قول لینک به ارسال
پست های پیشنهاد شده
به گفتگو بپیوندید
هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .