첨부파일 다운로드시 글 작성자에게 포인트 지급

안녕하세요^^

첨부파일 다운로드 시 글 작성자에게 일부 포인트를 지급하고 싶은데 가능할까요?

예를들어
파일을 첨부하여 글 작성 시
다운로드 하는사람은 포인트 -10감소(이건 게시판 설정에서 가능한데)
글 작성자에게는 포인트 +2증가

이런식으로 하고 싶습니다.
워드프레스 에러 기술지원 서비스 전문가에게 맡기세요
좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기
  • 안녕하세요~^^

    KBaord 플러그인에서 첨부파일 다운로드 감소 포인트를 설정했을 때

    글 작성자의 포인트를 2 증가하게 하시려면

    워드프레스 관리자 -> 외모 -> 테마 편집기 페이지에서 functions.php 파일 하단에

    아래의 코드를 추가해보시겠어요?

    add_action('kboard_file_download', 'my_kboard_file_download', 10, 4);
    function my_kboard_file_download($file_info, $content, $board, $comment){
    	if($board->id == '1' && $board->meta->attachment_download_down_point){
    		if(function_exists('mycred_add')){
    			if(!is_user_logged_in()){
    				do_action('kboard_cannot_download_file', 'go_back', wp_get_referer(), $content, $board, $comment);
    				exit;
    			}
    			else if($content->member_uid != get_current_user_id()){
    				$log_args['user_id'] = get_current_user_id();
    				$log_args['ref'] = 'attachment_download_down_point';
    				$log_args['ref_id'] = $content->uid;
    				$log = new myCRED_Query_Log($log_args);
    				
    				if(!$log->have_entries()){
    					$balance = mycred_get_users_balance(get_current_user_id());
    					if($board->meta->attachment_download_down_point > $balance){
    						do_action('kboard_cannot_download_file', 'not_enough_points', wp_get_referer(), $content, $board, $comment);
    						exit;
    					}
    					else{
    						$point = intval(get_user_meta($content->member_uid, 'kboard_document_mycred_point', true));
    						update_user_meta($content->member_uid, 'kboard_document_mycred_point', $point + 2);
    						
    						mycred_add('attachment_download_up_point', $content->member_uid, 2, '첨부파일 다운로드 증가 포인트', $content->uid);
    					}
    				}
    			}
    		}
    	}
    }

    위의 코드에서 $board->id == '1' 부분은 실제 게시판 id로 적용해보세요.

    고맙습니다.

워드프레스 에러 기술지원 서비스 전문가에게 맡기세요