-
-
Save tech-suey/abe0de8ba8a8f63fc221204033a98a7f to your computer and use it in GitHub Desktop.
Empty WordPress plugin
This file contains hidden or 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: Name Of The Plugin | |
| * Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates | |
| * Description: A brief description of the Plugin. | |
| * Version: The Plugin's Version Number, e.g.: 1.0 | |
| * Author: Name Of The Plugin Author | |
| * Author URI: http://URI_Of_The_Plugin_Author | |
| * License: A "Slug" license name e.g. GPL2 | |
| */ | |
| /* Copyright YEAR PLUGIN_AUTHOR_NAME (email : PLUGIN AUTHOR EMAIL) | |
| This program is free software; you can redistribute it and/or modify | |
| it under the terms of the GNU General Public License, version 2, as | |
| published by the Free Software Foundation. | |
| This program is distributed in the hope that it will be useful, | |
| but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| GNU General Public License for more details. | |
| You should have received a copy of the GNU General Public License | |
| along with this program; if not, write to the Free Software | |
| Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
| */ | |
| // Start writing code after this line! | |
| function wppbc_fv_check_if_user_locked( $message, $field, $request_data, $form_location, $form_role = '', $user_id = 0 ) { | |
| // Handle visibility for register form | |
| if( $form_location == 'register' ) { | |
| // Visibility for User Locked option | |
| if( !current_user_can( apply_filters( 'wppb_fv_capability_user_locked', 'manage_options' ) ) ) { | |
| if (isset($field['visibility']) && ($field['visibility'] == 'user_locked')) { | |
| remove_filter('wppb_check_form_field_' . Wordpress_Creation_Kit_PB::wck_generate_slug( $field['field'] ), 'wppb_in_fv_check_field_value', 11); | |
| remove_filter('wppb_check_form_field_' . Wordpress_Creation_Kit_PB::wck_generate_slug( $field['field'] ), 'wppb_in_fv_check_if_user_locked', 11); | |
| } | |
| } | |
| } | |
| return $message; | |
| } | |
| function wppbc_init_field_visibility() { | |
| if ( !defined('WPPBFV_IN_PLUGIN_DIR') ){ | |
| return; | |
| } | |
| $filter_fields = wppb_in_field_visibility_get_extra_fields(); | |
| // add filters for the fields | |
| foreach( $filter_fields as $filter_field_slug => $filter_field ) { | |
| if( class_exists('Wordpress_Creation_Kit_PB') ) { | |
| add_filter('wppb_check_form_field_' . Wordpress_Creation_Kit_PB::wck_generate_slug( $filter_field ), 'wppbc_fv_check_if_user_locked', 10, 6); | |
| } | |
| } | |
| } | |
| add_action( 'init', 'wppbc_init_field_visibility', 999 ); | |
| /* | |
| * Make field visibility user locked on the Edit Profile page only | |
| */ | |
| add_filter( 'wppb_output_display_form_field', 'wppbc_handle_output_display_state', 999, 5 ); | |
| function wppbc_handle_output_display_state( $display_field, $field, $form_location, $form_role, $user_id ){ | |
| // Handle visibility for register form | |
| if( $form_location == 'register' ) { | |
| // Visibility for User Locked option | |
| if( !current_user_can( apply_filters( 'wppb_fv_capability_user_locked', 'manage_options' ) ) ) { | |
| if (isset($field['visibility']) && ($field['visibility'] == 'user_locked')) { | |
| $display_field = true; | |
| } | |
| } | |
| } | |
| return $display_field; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment