Advertisement
Guest User

Points for Bp Media

a guest
Feb 19th, 2013
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.42 KB | None | 0 0
  1. <?php
  2.  
  3. // Register the module
  4. cp_module_register( __( 'Points for Bp media', 'cp' ) , 'bp_media' , '1.0', '<a href="http://www.taraj.sk">Taraj.sk</a>', 'http://www.taraj.sk', 'http://taraj.sk/' , __( 'Points for add photos, videos or music', 'cp' ), 1 );
  5.  
  6. // On installation, we set the default values for our custom points transactions.
  7. function cp_bp_media_install()
  8. {
  9.     add_option( 'cp_bp_media_value1', 10 );
  10.  
  11. }
  12. add_action( 'cp_module_bp_media_activate', 'cp_bp_media_install' );
  13.  
  14. // If the module is active.
  15. if ( cp_module_activated( 'bp_media' ) )
  16. {
  17.     // Add a function to display the form inputs.
  18.     function cp_bp_media_config()
  19.     {
  20.  
  21.     ?>
  22.         <br />
  23.         <h3><?php _e( 'Points for Bp media','cp' ); ?></h3>
  24.         <table class="form-table">
  25.             <tr valign="top">
  26.                 <th scope="row">
  27.                     <label for="cp_bp_media_value1"><?php _e( 'Points for add photos, videos or music', 'cp' ); ?>:</label>
  28.                 </th>
  29.                 <td valign="middle">
  30.                     <input type="text" id="cp_bp_media_value1" name="cp_bp_media_value1" value="<?php echo( get_option( 'cp_bp_media_value1' ) ); ?>" size="30" />
  31.                 </td>
  32.             </tr>
  33.            
  34.         </table>
  35.  
  36.     <?php
  37.  
  38.     }
  39.     add_action( 'cp_config_form','cp_bp_media_config' );
  40.  
  41.     // Create a function to process the form inputs when the form is submitted.
  42.     function cp_bp_media_config_process()
  43.     {
  44.         // We update the options with the submitted values. We cast them as integers.
  45.         update_option( 'cp_bp_media_value1', (int)$_POST['cp_bp_media_value1'] );
  46.  
  47.     }
  48.     add_action( 'cp_config_process','cp_bp_media_config_process' );
  49.      
  50. }
  51.  
  52.  
  53.  
  54. add_action('bp_media_after_add_media','my_bp_media_add_cp');
  55. // Log
  56. add_action('cp_logs_description','cp_bp_media_log', 10, 4);
  57. function cp_bp_media_log($type,$uid,$points,$data){
  58. if($type!='cp_bp_media') { return; }
  59. _e('Add Media','cp_buddypress');
  60. }
  61.  
  62.  
  63.  
  64. function my_bp_media_add_cp() {
  65.  
  66.     global $bp;
  67.  
  68.     $bpcpspamlist = explode(',' , get_option( 'bp_spammer_cp_bp' ) );
  69.  
  70.     foreach ( $bpcpspamlist as $spammer_id ) {
  71.  
  72.         if ($bp->loggedin_user->id == $spammer_id ) {  
  73.             $is_spammer = true;
  74.             break;
  75.         }
  76.         else {
  77.             $is_spammer = false;
  78.         }
  79.  
  80.     }
  81.  
  82.     if ($is_spammer == false) {
  83.         cp_points('cp_bp_media', $bp->loggedin_user->id, get_option('cp_bp_media_value1'), "");    
  84.     }
  85.  
  86. }
  87.  
  88.  
  89.  
  90.  
  91. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement