Title: Add to php
Last modified: September 1, 2016

---

# Add to php

 *  [Tom W](https://wordpress.org/support/users/thomaswillfahrt/)
 * (@thomaswillfahrt)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/add-to-php/)
 * Hello,
 * i want to protect a submit button.
 * For example like this:
    [content_protector password=”pw”] <div class=”submit_button_wrapper”
   > <button class=”button cbrp-button cbrp-button-form-‘ . $ratingFormArray[‘id’].‘”
   data-hash = “‘.$user_hash.'” data-buddypress-post = “‘.$buddypress_post.'” id
   =”submit-rating” type=”submit” name=”op” value=””><span id=”cbrp-button-label”
   >’ . __( ‘Submit’, ‘cbratingsystem’ ) . ‘</span></button> <div style=”display:
   none;” class=”cbrp_load_more_waiting_icon cbrp_load_more_waiting_icon_form-‘ .
   $ratingFormArray[‘id’] . ‘_post-‘ . $post_id . ‘”><img alt=”‘ . __( ‘Loading’,‘
   cbratingsystem’ ) . ‘” src=”‘ . CB_RATINGSYSTEM_PLUGIN_DIR_URL . ‘images/ajax-
   loader.gif” /></div> </div>[/content_protector]
 * How can i do this??
 * Thanks a lot
 * [https://wordpress.org/plugins/content-protector/](https://wordpress.org/plugins/content-protector/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [K. Tough](https://wordpress.org/support/users/kjvtough/)
 * (@kjvtough)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/add-to-php/#post-7533839)
 * Hi, Tom W.
 * Are you trying to do this in a Theme file? The usual method is to use `do_shortcode()`
   like this:
 *     ```
       $protected = '<div class="submit_button_wrapper">
       <button class="button cbrp-button cbrp-button-form-' . $ratingFormArray['id'] . '" data-hash = "'.$user_hash.'" data-buddypress-post = "'.$buddypress_post.'" id="submit-rating" type="submit" name="op" value=""><span id="cbrp-button-label">' . __( 'Submit', 'cbratingsystem' ) . '</span></button>
       <div style="display: none;" class="cbrp_load_more_waiting_icon cbrp_load_more_waiting_icon_form-' . $ratingFormArray['id'] . '_post-' . $post_id . '"><img alt="' . __( 'Loading', 'cbratingsystem' ) . '" src="' . CB_RATINGSYSTEM_PLUGIN_DIR_URL . 'images/ajax-loader.gif" /></div>
       </div>';
       echo do_shortcode( '[content_protector password="pw"]' . $protected . '[/content_protector]' );
       ```
   
 * You can also check the “Shortcode in Template” sticky topic for more info.
 *  Thread Starter [Tom W](https://wordpress.org/support/users/thomaswillfahrt/)
 * (@thomaswillfahrt)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/add-to-php/#post-7533878)
 * Hello,
 * thanks a lot.
    I try it in a plugin but it doesnt work.
 * $display .= ‘
    <div style=”clear:both;”></div> </div> <div style=”clear:both;”
   ></div> <div class=”submit_button_wrapper”> <button class=”button cbrp-button
   cbrp-button-form-‘ . $ratingFormArray[‘id’] . ‘” data-hash = “‘.$user_hash.'”
   data-buddypress-post = “‘.$buddypress_post.'” id=”submit-rating” type=”submit”
   name=”op” value=””><span id=”cbrp-button-label”>’ . __( ‘Submit’, ‘cbratingsystem’).‘
   </span></button> <div style=”display: none;” class=”cbrp_load_more_waiting_icon
   cbrp_load_more_waiting_icon_form-‘ . $ratingFormArray[‘id’] . ‘_post-‘ . $post_id.‘”
   ><img alt=”‘ . __( ‘Loading’, ‘cbratingsystem’ ) . ‘” src=”‘ . CB_RATINGSYSTEM_PLUGIN_DIR_URL.‘
   images/ajax-loader.gif” /></div> </div>
 *  <div style=”clear:both;”></div>
    </div> <div class=”ratingFormStatus ratingFormStatus-
   form-‘ . $ratingFormArray[‘id’] . ‘”></div>
 *  ‘;
 *  }
    $display .='</div>’;
 * TW
 *  Thread Starter [Tom W](https://wordpress.org/support/users/thomaswillfahrt/)
 * (@thomaswillfahrt)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/add-to-php/#post-7533881)
 * The submit button is not included in the form … so i cant send the form
 * $display .= ‘
    <div style=”clear:both;”></div> </div> <div style=”clear:both;”
   ></div>’;
 *  $protected = ‘<div class=”submit_button_wrapper”>
    <button class=”button cbrp-
   button cbrp-button-form-‘ . $ratingFormArray[‘id’] . ‘” data-hash = “‘.$user_hash.'”
   data-buddypress-post = “‘.$buddypress_post.'” id=”submit-rating” type=”submit”
   name=”op” value=””><span id=”cbrp-button-label”>’ . __( ‘Submit’, ‘cbratingsystem’).‘
   </span></button> <div style=”display: none;” class=”cbrp_load_more_waiting_icon
   cbrp_load_more_waiting_icon_form-‘ . $ratingFormArray[‘id’] . ‘_post-‘ . $post_id.‘”
   ><img alt=”‘ . __( ‘Loading’, ‘cbratingsystem’ ) . ‘” src=”‘ . CB_RATINGSYSTEM_PLUGIN_DIR_URL.‘
   images/ajax-loader.gif” /></div> </div>’; echo do_shortcode( ‘[content_protector
   password=”pw”]’ . $protected . ‘[/content_protector]’ );’
 *  </div>
    <div style=”clear:both;”></div> </div>
 *  [K. Tough](https://wordpress.org/support/users/kjvtough/)
 * (@kjvtough)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/add-to-php/#post-7533937)
 * When you say “I try it in a plugin”, do you mean you’re actually writing a plugin
   and you’re trying to use Content Protector as a part of your plugin?
 *  Thread Starter [Tom W](https://wordpress.org/support/users/thomaswillfahrt/)
 * (@thomaswillfahrt)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/add-to-php/#post-7533990)
 * No. I try to integrate the password protection in an existing plugin.
    I can 
   not create a plugin itself . . .
 * 😉
 *  [K. Tough](https://wordpress.org/support/users/kjvtough/)
 * (@kjvtough)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/add-to-php/#post-7533993)
 * A few things:
    - When posting code here, use the `code` tags; otherwise, your code gets messed
      up and hard to read.
    - You need to ensure Content Protector is loaded before your existing plugin.
    - Are you getting any syntax errors?
    - You need to make sure the entire block of HTML/PHP code you want to protect
      is assigned to `$protected`

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Add to php’ is closed to new replies.

 * ![](https://ps.w.org/content-protector/assets/icon-256x256.png?rev=2206760)
 * [Passster - Password Protect Pages and Content](https://wordpress.org/plugins/content-protector/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/content-protector/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/content-protector/)
 * [Active Topics](https://wordpress.org/support/plugin/content-protector/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/content-protector/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/content-protector/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [K. Tough](https://wordpress.org/support/users/kjvtough/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/add-to-php/#post-7533993)
 * Status: not resolved