Advertisement
Guest User

Points for Wp Pro Quiz

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