aryamehraboon 1 ارسال شده در آبان 93 گزارش بازنشر ارسال شده در آبان 93 (ویرایش شده) با سلاممن در حال راه اندازی یک وبسایت هستم که در اون از بادی پرس و ووکامرس استفاده شده.من میخوام یک نوتیفیکیشن سفارشی ایجاد کنم ، به این صورت که هر زمان که محصولی به فروشگاه اضافه میشه برای کاربران،یک نوتیفیکیشن مثل نوتیفیکیشن های دیگه بادی پرس ظاهر بشهمقالات زیادی رو هم خوندم اما حقیقتا متوجه نشدمکسی میتونه راهنمایی کنه؟این هم لیست مقالاتhttp://androoha.com/...s-buddypress-enhttp://stackoverflow...n-in-buddypresshttps://buddypress.o...-notifications/با تشکر ویرایش شده آبان 93 توسط aryamehraboon نقل قول لینک به ارسال
aghajoon 20 ارسال شده در آبان 93 گزارش بازنشر ارسال شده در آبان 93 (ویرایش شده) سلام میخوای به همه کاربرها ارسال بشه؟ یا دوستان خودت؟ ویرایش شده آبان 93 توسط aghajoon 1 نقل قول لینک به ارسال
aryamehraboon 1 ارسال شده در آبان 93 مالک گزارش بازنشر ارسال شده در آبان 93 سلام میخوام برای friend هام فرستاده بشه نقل قول لینک به ارسال
aghajoon 20 ارسال شده در آبان 93 گزارش بازنشر ارسال شده در آبان 93 سلام این کد برای همه کاربرها ارسال میکنه اما اگر بخواهی فقط برای دوستان خودت ارسال بشه باید یک تغییراتی درش ایجاد بشه شاید بتونم به عنوان پلاگین در مخزن وردپرس قرارش بدم<?php/*Plugin Name: BP notification woocommercePlugin URI: http://webcaffe.irDescription: Send notification buddypress for all member when publish woocommerce product .Version: 0.1Author: asghar hatampoorAuthor URI: http://webcaffe.ir*/define("BP_PRODUCT_NOTIFIER_SLUG","pro_notification"); function bp_product_setup_globals() {global $bp, $current_blog; $bp->bp_product=new stdClass(); $bp->bp_product->id = 'bp_product'; $bp->bp_product->slug = BP_PRODUCT_NOTIFIER_SLUG; $bp->bp_product->notification_callback = 'product_format_notifications_webcaffe';//show the notification $bp->active_components[$bp->bp_product->id] = $bp->bp_product->id; do_action( 'bp_product_setup_globals' ); } add_action( 'bp_setup_globals', 'bp_product_setup_globals' );function product_send_notification_webcaffe($id){ global $bp, $wpdb; $savedPost = get_post($id); if($savedPost->post_status == "publish" && $savedPost->post_type=="product" && !wp_is_post_revision($id)){ foreach( $wpdb->get_col( "SELECT ID FROM $wpdb->users" ) as $user_id): bp_core_add_notification($savedPost->ID, $user_id , $bp->bp_product->id, 'new_product_'.$savedPost->ID, $savedPost->post_author); endforeach; }}add_action('save_post','product_send_notification_webcaffe');function product_format_notifications_webcaffe( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { do_action( 'product_format_notifications_webcaffe', $action, $item_id, $secondary_item_id, $total_items, $format ); $createdPost = get_post($item_id); $creator = get_userdata($secondary_item_id); $text = '</a> <div id="'.$action.'"class="notification">'. __("There is a new product ", "bp-product").' <a class="ab-item" title="'.$createdPost->post_title.'"href="'.get_permalink( $item_id ).'"> '.__("check it out!", "bp-product").' </a> </div>'; return $text;}function product_remove_notification_webcaffe($savedPost){ global $bp;$savedPost = get_post($id); $user_id=$bp->loggedin_user->id; $item_id=$_POST['item_id']; $component_name='bp_product'; $component_action='new_product_'.$savedPost->ID; bp_core_delete_notifications_by_item_id ($user_id, $item_id, $component_name, $component_action); }add_action('woocommerce_single_product_summary','product_remove_notification_webcaffe',10,2);?> 2 نقل قول لینک به ارسال
aryamehraboon 1 ارسال شده در آبان 93 مالک گزارش بازنشر ارسال شده در آبان 93 سلام این کد برای همه کاربرها ارسال میکنه اما اگر بخواهی فقط برای دوستان خودت ارسال بشه باید یک تغییراتی درش ایجاد بشه شاید بتونم به عنوان پلاگین در مخزن وردپرس قرارش بدم<?php/*Plugin Name: BP notification woocommercePlugin URI: http://webcaffe.irDescription: Send notification buddypress for all member when publish woocommerce product .Version: 0.1Author: asghar hatampoorAuthor URI: http://webcaffe.ir*/define("BP_PRODUCT_NOTIFIER_SLUG","pro_notification"); function bp_product_setup_globals() {global $bp, $current_blog; $bp->bp_product=new stdClass(); $bp->bp_product->id = 'bp_product'; $bp->bp_product->slug = BP_PRODUCT_NOTIFIER_SLUG; $bp->bp_product->notification_callback = 'product_format_notifications_webcaffe';//show the notification $bp->active_components[$bp->bp_product->id] = $bp->bp_product->id; do_action( 'bp_product_setup_globals' ); } add_action( 'bp_setup_globals', 'bp_product_setup_globals' );function product_send_notification_webcaffe($id){ global $bp, $wpdb; $savedPost = get_post($id); if($savedPost->post_status == "publish" && $savedPost->post_type=="product" && !wp_is_post_revision($id)){ foreach( $wpdb->get_col( "SELECT ID FROM $wpdb->users" ) as $user_id): bp_core_add_notification($savedPost->ID, $user_id , $bp->bp_product->id, 'new_product_'.$savedPost->ID, $savedPost->post_author); endforeach; }}add_action('save_post','product_send_notification_webcaffe');function product_format_notifications_webcaffe( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { do_action( 'product_format_notifications_webcaffe', $action, $item_id, $secondary_item_id, $total_items, $format ); $createdPost = get_post($item_id); $creator = get_userdata($secondary_item_id); $text = '</a> <div id="'.$action.'"class="notification">'. __("There is a new product ", "bp-product").' <a class="ab-item" title="'.$createdPost->post_title.'"href="'.get_permalink( $item_id ).'"> '.__("check it out!", "bp-product").' </a> </div>'; return $text;}function product_remove_notification_webcaffe($savedPost){ global $bp;$savedPost = get_post($id); $user_id=$bp->loggedin_user->id; $item_id=$_POST['item_id']; $component_name='bp_product'; $component_action='new_product_'.$savedPost->ID; bp_core_delete_notifications_by_item_id ($user_id, $item_id, $component_name, $component_action); }add_action('woocommerce_single_product_summary','product_remove_notification_webcaffe',10,2);?>شما یدونه باشی امتحان میکنم خبر میدم نقل قول لینک به ارسال
aryamehraboon 1 ارسال شده در آبان 93 مالک گزارش بازنشر ارسال شده در آبان 93 @AGHAJOONعالیییییییی کار میکنه ممنونفقط امکانش هست توضیح بدین که چجوری باید این کار رو انجام داد؟بازم ممنون نقل قول لینک به ارسال
aghajoon 20 ارسال شده در آبان 93 گزارش بازنشر ارسال شده در آبان 93 (ویرایش شده) این کد برای همه کاربرهای سایت ارسال میکنه اگه بخوای فقط برای دوستان خودت در بادی پرس ارسال بشه باید بجایif($savedPost->post_status == "publish" && $savedPost->post_type=="product" && !wp_is_post_revision($id)){ foreach( $wpdb->get_col( "SELECT ID FROM $wpdb->users" ) as $user_id): bp_core_add_notification($savedPost->ID, $user_id , $bp->bp_product->id, 'new_product_'.$savedPost->ID, $savedPost->post_author); endforeach; }این کد را قرار بدیif(function_exists("friends_get_friend_user_ids") && $savedPost->post_status == "publish" && $savedPost->post_type=="product" && !wp_is_post_revision($id) ){ $friends = friends_get_friend_user_ids($savedPost->post_author); foreach($friends as $friend): bp_core_add_notification($savedPost->ID, $friend , $bp->bp_product->id, 'new_product_'.$savedPost->ID, $savedPost->post_author); endforeach;}پلاگینش را کامل کردم که عکس محصول هم نمایش میده و دارای فایل زبان هم هست برای وردپرس ارسال کردم اگه قبول شد لینکش را اینجا میذارم ویرایش شده آبان 93 توسط aghajoon 1 نقل قول لینک به ارسال
علی زینلی 2114 ارسال شده در آبان 93 گزارش بازنشر ارسال شده در آبان 93 این کد برای همه کاربرهای سایت ارسال میکنه اگه بخوای فقط برای دوستان خودت در بادی پرس ارسال بشه باید بجای if($savedPost->post_status == "publish" && $savedPost->post_type=="product" && !wp_is_post_revision($id)){ foreach( $wpdb->get_col( "SELECT ID FROM $wpdb->users" ) as $user_id): bp_core_add_notification($savedPost->ID, $user_id , $bp->bp_product->id, 'new_product_'.$savedPost->ID, $savedPost->post_author); endforeach; } این کد را قرار بدی if(function_exists("friends_get_friend_user_ids") && $savedPost->post_status == "publish" && $savedPost->post_type=="post" && !wp_is_post_revision($id) ){ $friends = friends_get_friend_user_ids($savedPost->post_author); foreach($friends as $friend): bp_core_add_notification($savedPost->ID, $friend , $bp->bp_product->id, 'new_product_'.$savedPost->ID, $savedPost->post_author); endforeach; } پلاگینش را کامل کردم که عکس محصول هم نمایش میده و دارای فایل زبان هم هست برای وردپرس ارسال کردم اگه قبول شد لینکش را اینجا میذارم عالیه ، موفّق باشی 1 نقل قول لینک به ارسال
aghajoon 20 ارسال شده در آبان 93 گزارش بازنشر ارسال شده در آبان 93 این عکسش هست نقل قول لینک به ارسال
aghajoon 20 ارسال شده در آبان 93 گزارش بازنشر ارسال شده در آبان 93 دانلود افزونه از مخزن وردپرس 1 نقل قول لینک به ارسال
پست های پیشنهاد شده
به گفتگو بپیوندید
هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .