Created
July 25, 2015 21:59
-
-
Save stephywells/6b4a4cbf381e26716f62 to your computer and use it in GitHub Desktop.
Send Formidable uploads to Media Value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Formidable MediaVault | |
* Plugin URI: https://www.formidablepro.com | |
* Description: This plugin will allow you to use | |
* Version: 1.0.0 | |
* Author: Strategy11 | |
* Author URI: http://strategy11.com | |
* License: GPL2 | |
*/ | |
/** | |
* Add MediaVault Pro Field | |
*/ | |
add_filter( 'frm_pro_available_fields', 'add_mediavault_field' ); | |
function add_mediavault_field( $fields ) { | |
$fields['mediavault'] = __( 'Media Vault' ); // the key for the field and the label | |
return $fields; | |
} | |
/** | |
* Show MediaVault Field in Form Builder | |
* This will add the field to the pro fields section of the form | |
* builder. | |
*/ | |
add_action( 'frm_display_added_fields', 'show_the_mediavault_field' ); | |
function show_the_mediavault_field( $field ) { | |
if ( $field['type'] != 'mediavault') { | |
return; | |
} | |
?> | |
<div style="width:100%;margin-bottom:10px;text-align:center;"> | |
<div class="howto button-secondary frm_html_field"> | |
By placing this field in your form, and a file upload<br> | |
field in your form, any files that are uploaded will go<br> | |
into the secure mediavault folder in your <br> | |
Wordpress Uploads folder. | |
</div> | |
</div> | |
<?php | |
} | |
/** | |
* Set MediaVault Pro Field Options | |
* This will customize set the label of the field to be hidden by default. | |
*/ | |
add_filter( 'frm_display_field_options', 'mv_display_field_options' ); | |
function mv_display_field_options( $display ) { | |
if ( $display['type'] == 'mediavault' ) { | |
$display['required'] = false; | |
$display['visibility'] = false; | |
$display['css'] = false; | |
$display['logic'] = false; | |
$display['label_position'] = false; | |
$display['description'] = false; | |
} | |
return $display; | |
} | |
/** | |
* Show MediaVault Pro Field in Forms | |
*/ | |
add_action( 'frm_form_fields', 'show_my_mediavault_field', 10, 2 ); | |
function show_my_mediavault_field( $field, $field_name ) { | |
if ( $field['type'] != 'mediavault' ) { | |
return; | |
} | |
?> | |
<input type="hidden" id="field_<?php echo esc_attr( $field['field_key'] ) ?>" name="mgjp_mv_protected" value="on" <?php do_action( 'frm_field_input_html', $field ) ?>/> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment