예제 #1
0
	function bp_xprofile_data_template( $user_id, $profile_group_id ) {
		$this->groups = BP_XProfile_Group::get( array(
			'profile_group_id' => $profile_group_id,
			'user_id' => $user_id,
			'hide_empty_groups' => true,
			'fetch_fields' => true,
			'fetch_field_data' => true
		) );

		$this->group_count = count($this->groups);
		$this->user_id = $user_id;
	}
function bppp_retrieve_profile_fields()
{
    if (!($groups = wp_cache_get('xprofile_groups_inc_empty', BuddyPress_Profile_Progression()->prefix))) {
        $groups = BP_XProfile_Group::get(array('fetch_fields' => true));
        wp_cache_set('xprofile_groups_inc_empty', $groups, BuddyPress_Profile_Progression()->prefix);
    }
    foreach ((array) $groups as $group) {
        foreach ((array) $group->fields as $key => $field) {
            $fields[] = $field;
        }
    }
    return $fields;
}
function buatp_get_all_profile_groups()
{
    if (class_exists('BP_XProfile_Group')) {
        $group_obj = BP_XProfile_Group::get();
        foreach ($group_obj as $groups) {
            if (!$i) {
                $i++;
                continue;
            }
            $arr[$groups->id] = $groups->name;
        }
        return (array) $arr;
    }
}
 function bp_xprofile_template($user_id, $profile_group_id)
 {
     if (!$profile_group_id) {
         if (!($this->groups = wp_cache_get('xprofile_groups', 'bp'))) {
             $this->groups = BP_XProfile_Group::get_all(true);
             wp_cache_set('xprofile_groups', $this->groups, 'bp');
         }
     } else {
         if (!($this->groups = wp_cache_get('xprofile_group_' . $profile_group_id, 'bp'))) {
             $this->groups = new BP_XProfile_Group($profile_group_id);
             wp_cache_set('xprofile_group_' . $profile_group_id, 'bp');
         }
         /* We need to put this single group into the same format as multiple group (an array) */
         $this->groups = array($this->groups);
     }
     $this->group_count = count($this->groups);
     $this->user_id = $user_id;
 }
 /**
  * @return array
  */
 protected static function list_profiles_fields()
 {
     if (!empty(self::$profiles_field_list)) {
         return self::$profiles_field_list;
     }
     global $wpdb;
     //https://buddypress.org/support/topic/how-to-get-list-of-xprofile-filds/#post-227700
     $profile_groups = BP_XProfile_Group::get(array('fetch_fields' => true));
     $fields2 = array();
     if (!empty($profile_groups)) {
         foreach ($profile_groups as $profile_group) {
             if (!empty($profile_group->fields)) {
                 $group_name = $profile_group->name;
                 foreach ($profile_group->fields as $field) {
                     //  echo $field->id . ' - ' . $field->name . '<br/>';
                     $id = 'bp_' . str_replace(" ", "_", $field->name);
                     $fields2[$id] = sprintf(__('BP %s profile: %s', 'author-avatars'), $group_name, $field->name);
                 }
             }
         }
     }
     self::$profiles_field_list = $fields2;
     return self::$profiles_field_list;
 }
예제 #6
0
    /**
     * Render metabox content
     *
     * @param array $user_object
     * @author korotkov@UD
     */
    function bp_profile_fields_metabox($user_object)
    {
        global $bp;
        /** Set user id */
        $user_id = WP_CRM_F::get_first_value($user_object['ID']);
        $bp->displayed_user->id = $user_id;
        /** Get BP Profile groups */
        $bp_user_profile_groups = BP_XProfile_Group::get(array('user_id' => $user_id, 'fetch_fields' => 1, 'fetch_field_data' => 1, 'hide_empty_groups' => 1));
        $bp_user_profile_groups = apply_filters('wp_crm_bp_groups_before_render', $bp_user_profile_groups);
        if (!empty($bp_user_profile_groups) && is_array($bp_user_profile_groups)) {
            ?>
    <script type="text/javascript">
      if( typeof bp_clear_profile_field == 'undefined' ) {
        function bp_clear_profile_field(container) {
          if( !document.getElementById(container) ) return;
          var container = document.getElementById(container);
          if ( radioButtons = container.getElementsByTagName('INPUT') ) {
            for(var i=0; i<radioButtons.length; i++) {
              radioButtons[i].checked = '';
            }
          }
          if ( options = container.getElementsByTagName('OPTION') ) {
            for(var i=0; i<options.length; i++) {
              options[i].selected = false;
            }
          }
          return;
        }
      }
    </script>
    <table class="form-table bp-profile">
      <?php 
            foreach ($bp_user_profile_groups as $group_key => $group_object) {
                ?>
        <tr class="wp_crm_bp_group_name">
          <th colspan="2">
            <?php 
                ob_start();
                ?>
            <label>
              <?php 
                echo $group_object->name;
                ?>
            </label>
            <div class="wp_crm_description"><?php 
                echo $group_object->description;
                ?>
</div>
            <?php 
                $label = ob_get_contents();
                ob_end_clean();
                ?>
            <?php 
                echo apply_filters('wp_crm_bp_profile_group_name', $label, $group_object, $user_object);
                ?>
          </th>
        </tr>
        <?php 
                if (!empty($group_object->fields) && is_array($group_object->fields)) {
                    ?>
          <?php 
                    foreach ($group_object->fields as $field_key => $field_object) {
                        ?>
            <tr class="wp_crm_user_entry_row">
              <th>
                <?php 
                        ob_start();
                        ?>
                <label><?php 
                        echo $field_object->name;
                        ?>
</label>
                <div class="wp_crm_description"><?php 
                        echo $field_object->description;
                        ?>
</div>
                <?php 
                        $label = ob_get_contents();
                        ob_end_clean();
                        ?>
                <?php 
                        echo apply_filters('wp_crm_bp_profile_field_name', $label, $field_object, $user_object);
                        ?>
              </th>
              <td class="wp_crm_user_data_row">
                <div class="input_div">
                  <?php 
                        if ($field_object->name == bp_xprofile_fullname_field_name()) {
                            ?>
                  <div class="bp readonly">
                    <input readonly="readonly" type="text" value="<?php 
                            echo $field_object->data->value;
                            ?>
" />
                  </div>
                  <?php 
                        } else {
                            ?>
                  <?php 
                            echo self::render_bp_field($field_object);
                            ?>
                  <?php 
                        }
                        ?>
                </div>
              </td>
            </tr>
          <?php 
                    }
                    ?>
        <?php 
                }
                ?>
      <?php 
            }
            ?>
    </table>
    <?php 
        }
    }
 function __construct($user_id, $profile_group_id, $hide_empty_groups = false, $fetch_fields = false, $fetch_field_data = false, $exclude_groups = false, $exclude_fields = false, $hide_empty_fields = false, $fetch_visibility_level = false, $update_meta_cache = true)
 {
     $this->groups = BP_XProfile_Group::get(array('profile_group_id' => $profile_group_id, 'user_id' => $user_id, 'hide_empty_groups' => $hide_empty_groups, 'hide_empty_fields' => $hide_empty_fields, 'fetch_fields' => $fetch_fields, 'fetch_field_data' => $fetch_field_data, 'fetch_visibility_level' => $fetch_visibility_level, 'exclude_groups' => $exclude_groups, 'exclude_fields' => $exclude_fields, 'update_meta_cache' => $update_meta_cache));
     $this->group_count = count($this->groups);
     $this->user_id = $user_id;
 }
    /**
     * Renders the input form for PopUp editor.
     *
     * @since  4.6
     * @param  string $name
     * @param  array $data
     */
    protected function render_form($name, $data)
    {
        if (!class_exists('BP_XProfile_Group')) {
            echo '<div class="error below-h2"><p>' . __('This condition requires that the BuddyPress Extended Profile component is active.', PO_LANG) . '</p></div>';
            return;
        }
        $xfields = array();
        $xgroups = BP_XProfile_Group::get(array('fetch_fields' => true));
        if (!empty($xgroups)) {
            foreach ($xgroups as $xgroup) {
                $xfields[$xgroup->name] = $xgroup->fields;
            }
        }
        if (empty($xfields)) {
            _e('No XProfile fields found.', PO_LANG);
        }
        ?>
		<label for="po-rule-data-<?php 
        echo esc_attr($name);
        ?>
-field">
			<?php 
        _e('Field:', PO_LANG);
        ?>
		</label>

		<select name="po_rule_data[<?php 
        echo esc_attr($name);
        ?>
][field]"
			id="po-rule-data-<?php 
        echo esc_attr($name);
        ?>
-field">
		<?php 
        foreach ($xfields as $group => $fields) {
            ?>
			<optgroup label="<?php 
            echo esc_attr($group);
            ?>
">
			<?php 
            foreach ($fields as $field) {
                ?>
				<option value="<?php 
                echo esc_attr($field->id);
                ?>
"
					<?php 
                selected($field->id, $data['field']);
                ?>
>
					<?php 
                echo esc_html($field->name);
                ?>
				</option>
			<?php 
            }
            ?>
			</optgroup>
		<?php 
        }
        ?>
		</select>


		<select name="po_rule_data[<?php 
        echo esc_attr($name);
        ?>
][correlation]">
		<option value="" <?php 
        selected($data['correlation'], '');
        ?>
>
			<?php 
        _e('equals', PO_LANG);
        ?>
		</option>
		<option value="reverse" <?php 
        selected($data['correlation'], 'reverse');
        ?>
>
			<?php 
        _e('is not', PO_LANG);
        ?>
		</option>
		<option value="regex_is" <?php 
        selected($data['correlation'], 'regex_is');
        ?>
>
			<?php 
        _e('matches regex', PO_LANG);
        ?>
		</option>
		<option value="regex_not" <?php 
        selected($data['correlation'], 'regex_not');
        ?>
>
			<?php 
        _e('does not match regex', PO_LANG);
        ?>
		</option>
		</select>

		<input type="text"
			name="po_rule_data[<?php 
        echo esc_attr($name);
        ?>
][value]"
			value="<?php 
        echo esc_attr($data['value']);
        ?>
" />
		<?php 
    }
 /**
  * Get all of the profile information for a specific user.
  *
  * @param int $user_id ID of the user.
  * @return array
  */
 public static function get_all_for_user($user_id)
 {
     global $wpdb, $bp;
     $groups = BP_XProfile_Group::get(array('user_id' => $user_id, 'hide_empty_groups' => true, 'hide_empty_fields' => true, 'fetch_fields' => true, 'fetch_field_data' => true));
     $profile_data = array();
     if (!empty($groups)) {
         $user = new WP_User($user_id);
         $profile_data['user_login'] = $user->user_login;
         $profile_data['user_nicename'] = $user->user_nicename;
         $profile_data['user_email'] = $user->user_email;
         foreach ((array) $groups as $group) {
             if (empty($group->fields)) {
                 continue;
             }
             foreach ((array) $group->fields as $field) {
                 $profile_data[$field->name] = array('field_group_id' => $group->id, 'field_group_name' => $group->name, 'field_id' => $field->id, 'field_type' => $field->type, 'field_data' => $field->data->value);
             }
         }
     }
     return $profile_data;
 }
예제 #10
0
 public static function get_buddypress_fields()
 {
     require_once WP_PLUGIN_DIR . '/buddypress/bp-xprofile/bp-xprofile-classes.php';
     // get BP field groups
     $groups = BP_XProfile_Group::get(array('fetch_fields' => true));
     $buddypress_fields = array();
     $i = 0;
     foreach ($groups as $group) {
         if (!is_array($group->fields)) {
             continue;
         }
         foreach ($group->fields as $field) {
             $buddypress_fields[$i]['name'] = $field->name;
             $buddypress_fields[$i]['value'] = $field->id;
             $i++;
         }
     }
     return $buddypress_fields;
 }
function acui_options()
{
    global $url_plugin;
    if (!current_user_can('create_users')) {
        wp_die(__('You are not allowed to see this content.'));
    }
    if (isset($_GET['tab'])) {
        $tab = $_GET['tab'];
    } else {
        $tab = 'homepage';
    }
    if (isset($_POST) && !empty($_POST)) {
        switch ($tab) {
            case 'homepage':
                acui_fileupload_process($_POST, false);
                return;
                break;
            case 'mail-template':
                acui_save_mail_template($_POST);
                break;
            case 'cron':
                acui_manage_cron_process($_POST);
                break;
        }
    }
    if (isset($_GET['tab'])) {
        acui_admin_tabs($_GET['tab']);
    } else {
        acui_admin_tabs('homepage');
    }
    switch ($tab) {
        case 'homepage':
            $args_old_csv = array('post_type' => 'attachment', 'post_mime_type' => 'text/csv', 'post_status' => 'inherit', 'posts_per_page' => -1);
            $old_csv_files = new WP_Query($args_old_csv);
            acui_check_options();
            ?>
	<div class="wrap">	

		<?php 
            if ($old_csv_files->found_posts > 0) {
                ?>
		<div class="postbox">
		    <div title="Click to open/close" class="handlediv">
		      <br>
		    </div>

		    <h3 class="hndle"><span>&nbsp;Old CSV files uploaded</span></h3>

		    <div class="inside" style="display: block;">
		    	<p>For security reasons you should delete this files, probably they would be visible in the Internet if a bot or someone discover the URL. You can delete each file or maybe you want delete all CSV files you have uploaded:</p>
		    	<input type="button" value="Delete all CSV files uploaded" id="bulk_delete_attachment" style="float:right;"></input>
		    	<ul>
		    		<?php 
                while ($old_csv_files->have_posts()) {
                    $old_csv_files->the_post();
                    if (get_the_date() == "") {
                        $date = "undefined";
                    } else {
                        $date = get_the_date();
                    }
                    ?>
		    		<li><a href="<?php 
                    echo wp_get_attachment_url(get_the_ID());
                    ?>
"><?php 
                    the_title();
                    ?>
</a> uploaded the <?php 
                    echo $date;
                    ?>
 <input type="button" value="Delete" class="delete_attachment" attach_id="<?php 
                    the_ID();
                    ?>
"></input></li>
		    		<?php 
                }
                ?>
		    		<?php 
                wp_reset_postdata();
                ?>
		    	</ul>
		        <div style="clear:both;"></div>
		    </div>
		</div>
		<?php 
            }
            ?>
	

		<div id='message' class='updated'>File must contain at least <strong>2 columns: username and email</strong>. These should be the first two columns and it should be placed <strong>in this order: username and email</strong>. If there are more columns, this plugin will manage it automatically.</div>
		<div id='message-password' class='error'>Please, read carefully how <strong>passwords are managed</strong> and also take note about capitalization, this plugin is <strong>case sensitive</strong>.</div>

		<div style="float:left; width:80%;">
			<h2>Import users from CSV</h2>
		</div>

		<div style="clear:both;"></div>

		<div style="width:100%;">
			<form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8" onsubmit="return check();">
			<table class="form-table">
				<tbody>
				<tr class="form-field">
					<th scope="row"><label for="role">Role</label></th>
					<td>
					<?php 
            $list_roles = acui_get_editable_roles();
            foreach ($list_roles as $key => $value) {
                if ($key == "subscriber") {
                    echo "<label style='margin-right:5px;'><input name='role[]' type='checkbox' checked='checked' value='{$key}'/>{$value}</label>";
                } else {
                    echo "<label style='margin-right:5px;'><input name='role[]' type='checkbox' value='{$key}'/>{$value}</label>";
                }
            }
            ?>

					<p class="description">If you choose more than one role, the roles would be assigned correctly but you should use some plugin like <a href="https://wordpress.org/plugins/user-role-editor/">User Role Editor</a> to manage them.</p>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label>CSV file <span class="description">(required)</span></label></th>
					<td>
						<div id="upload_file">
							<input type="file" name="uploadfiles[]" id="uploadfiles" size="35" class="uploadfiles" />
							<em>or you can choose directly a file from your host, <a href="#" class="toggle_upload_path">click here</a>.</em>
						</div>
						<div id="introduce_path" style="display:none;">
							<input placeholder="You have to introduce the path to file, i.e.: <?php 
            $upload_dir = wp_upload_dir();
            echo $upload_dir["path"];
            ?>
/test.csv" type="text" name="path_to_file" id="path_to_file" value="<?php 
            echo dirname(__FILE__);
            ?>
/test.csv" style="width:70%;" />
							<em>or you can upload it directly from your PC, <a href="#" class="toggle_upload_path">click here</a>.</em>
						</div>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label>What should do the plugin with empty cells?</label></th>
					<td>
						<select name="empty_cell_action">
							<option value="leave">Leave the old value for this metadata</option>
							<option value="delete">Delete the metadata</option>							
						</select>
					</td>
				</tr>

				<?php 
            if (is_plugin_active('buddypress/bp-loader.php')) {
                if (!class_exists("BP_XProfile_Group")) {
                    require_once WP_PLUGIN_DIR . "/buddypress/bp-xprofile/classes/class-bp-xprofile-group.php";
                }
                $buddypress_fields = array();
                $profile_groups = BP_XProfile_Group::get(array('fetch_fields' => true));
                if (!empty($profile_groups)) {
                    foreach ($profile_groups as $profile_group) {
                        if (!empty($profile_group->fields)) {
                            foreach ($profile_group->fields as $field) {
                                $buddypress_fields[] = $field->name;
                            }
                        }
                    }
                }
                ?>

				<tr class="form-field form-required">
					<th scope="row"><label>BuddyPress users</label></th>
					<td>You can insert any profile from BuddyPress using his name as header. Plugin will check, before import, which fields are defined in BuddyPress and will assign it in the update. You can use this fields:
					<ul style="list-style:disc outside none;margin-left:2em;">
						<?php 
                foreach ($buddypress_fields as $buddypress_field) {
                    ?>
<li><?php 
                    echo $buddypress_field;
                    ?>
</li><?php 
                }
                ?>
					</ul>
					Remember that all date fields have to be imported using a format like this: 2016-01-01 00:00:00

					<p class="description"><strong>(Only for <a href="https://wordpress.org/plugins/buddypress/">BuddyPress</a> users)</strong>.</p>
					</td>					
				</tr>

				<?php 
            }
            ?>

				<?php 
            if (is_plugin_active('wp-members/wp-members.php')) {
                ?>

				<tr class="form-field form-required">
					<th scope="row"><label>Y</label></th>
					<td>
						<select name="activate_users_wp_members">
							<option value="no_activate">Do not activate users</option>
							<option value="activate">Activate users when they are being imported</option>
						</select>

						<p class="description"><strong>(Only for <a href="https://wordpress.org/plugins/wp-members/">WP Members</a> users)</strong>.</p>
					</td>
					
				</tr>

				<?php 
            }
            ?>

				<?php 
            if (is_plugin_active('new-user-approve/new-user-approve.php')) {
                ?>

				<tr class="form-field form-required">
					<th scope="row"><label>Approve users at the same time is being created</label></th>
					<td>
						<select name="approve_users_new_user_appove">
							<option value="no_approve">Do not approve users</option>
							<option value="approve">Approve users when they are being imported</option>
						</select>

						<p class="description"><strong>(Only for <a href="https://es.wordpress.org/plugins/new-user-approve/">New User Approve</a> users)</strong>.</p>
					</td>
					
				</tr>

				<?php 
            }
            ?>

				<?php 
            if (is_plugin_active('allow-multiple-accounts/allow-multiple-accounts.php')) {
                ?>

				<tr class="form-field form-required">
					<th scope="row"><label>Repeated email in different users?</label></th>
					<td>
						<select name="allow_multiple_accounts">
							<option value="not_allowed">Not allowed</option>
							<option value="allowed">Allowed</option>
						</select>
						<p class="description"><strong>(Only for <a href="https://wordpress.org/plugins/allow-multiple-accounts/">Allow Multiple Accounts</a> users)</strong>. Allow multiple user accounts to be created having the same email address.</p>
					</td>
				</tr>

				<?php 
            }
            ?>

				<?php 
            if (is_plugin_active('wp-access-areas/wp-access-areas.php')) {
                ?>

				<tr class="form-field form-required">
					<th scope="row"><label>WordPress Access Areas is activated</label></th>
					<td>
						<p class="description">As user of <a href="https://wordpress.org/plugins/wp-access-areas/">WordPress Access Areas</a> you can use the Access Areas created <a href="<?php 
                echo admin_url('users.php?page=user_labels');
                ?>
">here</a> and use this areas in your own CSV file. Please use the column name <strong>wp-access-areas</strong> and in each row use <strong>the name that you have used <a href="<?php 
                echo admin_url('users.php?page=user_labels');
                ?>
">here</a></strong>, like this ones:</p>
						<ol>
							<?php 
                $data = WPAA_AccessArea::get_available_userlabels('0,5', NULL);
                foreach ($data as $access_area_object) {
                    ?>
									<li><?php 
                    echo $access_area_object->cap_title;
                    ?>
</li>
							<?php 
                }
                ?>

						</ol>
						<p class="description">If you leave this cell empty for some user or the access area indicated doesn't exist, user won't be assigned to any access area. You can choose more than one area for each user using pads between them in the same row, i.e.: access_area1#accces_area2</p>
					</td>
				</tr>

				<?php 
            }
            ?>

				<tr class="form-field">
					<th scope="row"><label for="user_login">Send mail</label></th>
					<td>
						<p>Do you wish to send a mail with credentials and other data? <input type="checkbox" name="sends_email" value = "yes"></p>
						<p>Do you wish to send this mail also to users that are being updated? (not only to the one which are being created) <input type="checkbox" name="send_email_updated" value = "yes" checked="checked"></p>
					</td>
				</tr>
				</tbody>
			</table>
			<input class="button-primary" type="submit" name="uploadfile" id="uploadfile_btn" value="Start importing"/>
			</form>
		</div>

	</div>
	<script type="text/javascript">
	function check(){
		if(document.getElementById("uploadfiles").value == "" && jQuery( "#upload_file" ).is(":visible") ) {
		   alert("Please choose a file");
		   return false;
		}

		if( jQuery( "#path_to_file" ).val() == "" && jQuery( "#introduce_path" ).is(":visible") ) {
		   alert("Please enter a path to the file");
		   return false;
		}

		if( jQuery("[name=role\\[\\]]input:checkbox:checked").length == 0 ){
			alert("Please select a role");
		   	return false;	
		}
	}

	jQuery( document ).ready( function( $ ){
		$( ".delete_attachment" ).click( function(){
			var answer = confirm( "Are you sure to delete this file?" );
			if( answer ){
				var data = {
					'action': 'acui_delete_attachment',
					'attach_id': $( this ).attr( "attach_id" )
				};

				$.post(ajaxurl, data, function(response) {
					if( response != 1 )
						alert( "There were problems deleting the file, please check file permissions" );
					else{
						alert( "File successfully deleted" );
						document.location.reload();
					}
				});
			}
		});

		$( "#bulk_delete_attachment" ).click( function(){
			var answer = confirm( "Are you sure to delete ALL CSV files uploaded? There can be CSV files from other plugins." );
			if( answer ){
				var data = {
					'action': 'acui_bulk_delete_attachment',
				};

				$.post(ajaxurl, data, function(response) {
					if( response != 1 )
						alert( "There were problems deleting the files, please check files permissions" );
					else{
						alert( "Files successfully deleted" );
						document.location.reload();
					}
				});
			}
		});

		$( ".toggle_upload_path" ).click( function( e ){
			e.preventDefault();

			$("#upload_file,#introduce_path").toggle();
		} );

	} );
	</script>

	<?php 
            break;
        case 'columns':
            $headers = get_option("acui_columns");
            ?>

		<h3>Custom columns loaded</h3>
		<table class="form-table">
		<tbody>
			<tr valign="top">
				<th scope="row">Columns loaded in previous files</th>
				<td><small><em>(if you load another CSV with different columns, the new ones will replace this list)</em></small>
					<ol>
						<?php 
            if (is_array($headers) && count($headers) > 0) {
                foreach ($headers as $column) {
                    ?>
							<li><?php 
                    echo $column;
                    ?>
</li>
						<?php 
                }
                ?>
						
						<?php 
            } else {
                ?>
							<li>There is no columns loaded yet</li>							
						<?php 
            }
            ?>
					</ol>
				</td>
			</tr>
		</tbody></table>

		<?php 
            break;
        case 'doc':
            ?>

		<h3>Documentation</h3>
		<table class="form-table">
		<tbody>
			<tr valign="top">
				<th scope="row">Columns position</th>
				<td><small><em>(Documents should look like the one presented into screenshot. Remember you should fill the first two columns with the next values)</em></small>
					<ol>
						<li>Username</li>
						<li>Email</li>
					</ol>						
					<small><em>(The next columns are totally customizable and you can use whatever you want. All rows must contains same columns)</em></small>
					<small><em>(User profile will be adapted to the kind of data you have selected)</em></small>
					<small><em>(If you want to disable the extra profile information, please deactivate this plugin after make the import)</em></small>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row">Passwords</th>
				<td>A string that contains user passwords. We have different options for this case:
					<ul style="list-style:disc outside none; margin-left:2em;">
						<li>If user is created: if you set a value for the password, it will be used; if not, it will be generated</li>
						<li>If user is updated: 
							<ul style="list-style:disc outside none;margin-left:2em;">
								<li>If you <strong>don't create a column for passwords</strong>: passwords will be generated automatically</li>
								<li>If you <strong>create a column for passwords</strong>: if cell is empty, password won't be updated; if cell has a value, it will be used</li>
							</ul>
					</ul>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row">WordPress default profile data</th>
				<td>You can use those labels if you want to set data adapted to the WordPress default user columns (the ones who use the function <a href="http://codex.wordpress.org/Function_Reference/wp_update_user">wp_update_user</a>)
					<ol>
						<li><strong>user_nicename</strong>: A string that contains a URL-friendly name for the user. The default is the user's username.</li>
						<li><strong>user_url</strong>: A string containing the user's URL for the user's web site.	</li>
						<li><strong>display_name</strong>: A string that will be shown on the site. Defaults to user's username. It is likely that you will want to change this, for both appearance and security through obscurity (that is if you don't use and delete the default admin user).</li>
						<li><strong>nickname</strong>: The user's nickname, defaults to the user's username.	</li>
						<li><strong>first_name</strong>: The user's first name.</li>
						<li><strong>last_name</strong>: The user's last name.</li>
						<li><strong>description</strong>: A string containing content about the user.</li>
						<li><strong>jabber</strong>: User's Jabber account.</li>
						<li><strong>aim</strong>: User's AOL IM account.</li>
						<li><strong>yim</strong>: User's Yahoo IM account.</li>
						<li><strong>user_registered</strong>: Using the WordPress format for this kind of data Y-m-d H:i:s.</li>
					</ol>
				</td>
			</tr>
			<?php 
            if (is_plugin_active('woocommerce/woocommerce.php')) {
                ?>

				<tr valign="top">
					<th scope="row">WooCommerce is activated</th>
					<td>You can use those labels if you want to set data adapted to the WooCommerce default user columns)
					<ol>
						<li>billing_first_name</li>
						<li>billing_last_name</li>
						<li>billing_company</li>
						<li>billing_address_1</li>
						<li>billing_address_2</li>
						<li>billing_city</li>
						<li>billing_postcode</li>
						<li>billing_country</li>
						<li>billing_state</li>
						<li>billing_phone</li>
						<li>billing_email</li>
						<li>shipping_first_name</li>
						<li>shipping_last_name</li>
						<li>shipping_company</li>
						<li>shipping_address_1</li>
						<li>shipping_address_2</li>
						<li>shipping_city</li>
						<li>shipping_postcode</li>
						<li>shipping_country</li>
						<li>shipping_state</li>
					</ol>
				</td>
				</tr>

				<?php 
            }
            ?>
			<tr valign="top">
				<th scope="row">Important notice</th>
				<td>You can upload as many files as you want, but all must have the same columns. If you upload another file, the columns will change to the form of last file uploaded.</td>
			</tr>
			<tr valign="top">
				<th scope="row">Any question about it</th>
				<td>
					<ul style="list-style:disc outside none; margin-left:2em;">
						<li>Free support (in WordPress forums): <a href="https://wordpress.org/support/plugin/import-users-from-csv-with-meta">https://wordpress.org/support/plugin/import-users-from-csv-with-meta</a>.</li>
						<li>Premium support (with a quote): <a href="mailto:contacto@codection.com">contacto@codection.com</a>.</li>
					</ul>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row">Example</th>
			<td>Download this <a href="<?php 
            echo plugins_url() . "/import-users-from-csv-with-meta/test.csv";
            ?>
">.csv file</a> to test</td> 
			</tr>
		</tbody>
		</table>
		<br/>
		<div style="width:775px;margin:0 auto"><img src="<?php 
            echo plugins_url() . "/import-users-from-csv-with-meta/csv_example.png";
            ?>
"/></div>
	<?php 
            break;
            ?>

	<?php 
        case 'mail-template':
            $from_email = get_option("acui_mail_from");
            $from_name = get_option("acui_mail_from_name");
            $body_mail = get_option("acui_mail_body");
            $subject_mail = get_option("acui_mail_subject");
            ?>
		<h3>Customize the email that can be sent when importing users</h3>

		<p class="description">You can set your own SMTP and other mail details <a href="<?php 
            echo admin_url('tools.php?page=acui-smtp');
            ?>
" target="_blank">here</a>.
		
		<form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8">
			<p>Mail subject : <input name="subject_mail" size="100" value="<?php 
            echo $subject_mail;
            ?>
" id="title" autocomplete="off" type="text"></p>
			<?php 
            wp_editor($body_mail, 'body_mail');
            ?>

			<br/>
			<input class="button-primary" type="submit" value="Save mail template"/>
		</form>
		
		<p>You can use:</p>
		<ul style="list-style-type:disc; margin-left:2em;">
			<li>**username** = username to login</li>
			<li>**password** = user password</li>
			<li>**loginurl** = current site login url</li>
			<li>**email** = user email</li>
			<li>You can also use any WordPress user standard field or an own metadata, if you have used it in your CSV. For example, if you have a first_name column, you could use **first_name** or any other meta_data like **my_custom_meta**</li>
		</ul>

	<?php 
            break;
            ?>

	<?php 
        case 'cron':
            $cron_activated = get_option("acui_cron_activated");
            $send_mail_cron = get_option("acui_send_mail_cron");
            $send_mail_updated = get_option("acui_send_mail_updated");
            $cron_delete_users = get_option("acui_cron_delete_users");
            $path_to_file = get_option("acui_cron_path_to_file");
            $period = get_option("acui_cron_period");
            $role = get_option("acui_cron_role");
            $log = get_option("acui_cron_log");
            if (empty($cron_activated)) {
                $cron_activated = false;
            }
            if (empty($send_mail_cron)) {
                $send_mail_cron = false;
            }
            if (empty($send_mail_updated)) {
                $send_mail_updated = false;
            }
            if (empty($cron_delete_users)) {
                $cron_delete_users = false;
            }
            if (empty($path_to_file)) {
                $path_to_file = dirname(__FILE__) . '/test.csv';
            }
            if (empty($period)) {
                $period = 'hourly';
            }
            if (empty($role)) {
                $role = "subscriber";
            }
            if (empty($log)) {
                $log = "No tasks done yet.";
            }
            ?>
		<h3>Execute an import of users periodically</h3>

		<form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8">
			<table class="form-table">
				<tbody>
				<tr class="form-field">
					<th scope="row"><label for="path_to_file">Path of file that are going to be imported</label></th>
					<td>
						<input placeholder="Insert complete path to the file" type="text" name="path_to_file" id="path_to_file" value="<?php 
            echo $path_to_file;
            ?>
" style="width:70%;" />
						<p class="description">You have to introduce the path to file, i.e.: <?php 
            $upload_dir = wp_upload_dir();
            echo $upload_dir["path"];
            ?>
/test.csv</p>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label for="period">Period</label></th>
					<td>
						<select id="period" name="period">
							<option <?php 
            if ($period == 'hourly') {
                echo "selected='selected'";
            }
            ?>
 value="hourly">Hourly</option>
							<option <?php 
            if ($period == 'twicedaily') {
                echo "selected='selected'";
            }
            ?>
 value="twicedaily">Twicedaily</option>
							<option <?php 
            if ($period == 'daily') {
                echo "selected='selected'";
            }
            ?>
 value="daily">Daily</option>
						</select>
						<p class="description">How often the event should reoccur?</p>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label for="cron-activated">Activate periodical import?</label></th>
					<td>
						<input type="checkbox" name="cron-activated" value="yes" <?php 
            if ($cron_activated == true) {
                echo "checked='checked'";
            }
            ?>
/>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label for="send-mail-cron">Send mail when using periodical import?</label></th>
					<td>
						<input type="checkbox" name="send-mail-cron" value="yes" <?php 
            if ($send_mail_cron == true) {
                echo "checked='checked'";
            }
            ?>
/>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label for="send-mail-updated">Send mail also to users that are being updated?</label></th>
					<td>
						<input type="checkbox" name="send-mail-updated" value="yes" <?php 
            if ($send_mail_updated == true) {
                echo "checked='checked'";
            }
            ?>
/>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label for="cron-delete-users">Delete users that are not present in the CSV?</label></th>
					<td>
						<input type="checkbox" name="cron-delete-users" value="yes" <?php 
            if ($cron_delete_users == true) {
                echo "checked='checked'";
            }
            ?>
/>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label for="role">Role</label></th>
					<td>
						<select id="role" name="role">
							<?php 
            $list_roles = acui_get_editable_roles();
            foreach ($list_roles as $key => $value) {
                if ($key == $role) {
                    echo "<option selected='selected' value='{$key}'>{$value}</option>";
                } else {
                    echo "<option value='{$key}'>{$value}</option>";
                }
            }
            ?>
						</select>
						<p class="description">Which role would be used to import users?</p>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label for="log">Last actions of schedule task</label></th>
					<td>
						<pre><?php 
            echo $log;
            ?>
</pre>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label for="mails">Mail sending</label></th>
					<td>Please take care: for this option, cron import, mail sending is not available in this version (if you need it <a href="mailto:contacto@codection.com">talk with us</a>)</td>
				</tr>
				</tbody>
			</table>
			<input class="button-primary" type="submit" value="Save schedule options"/>
		</form>

		<script>
		jQuery( document ).ready( function( $ ){
			$( "[name='cron-delete-users']" ).change(function() {
		        if( $(this).is( ":checked" ) ) {
		            var returnVal = confirm("Are you sure to delete all users that are not present in the CSV? This action cannto be undone.");
		            $(this).attr("checked", returnVal);
		        }
		        
		    });
		});
		</script>
	<?php 
            break;
            ?>

	<?php 
        case 'donate':
            ?>

	<div class="postbox">
	    <h3 class="hndle"><span>&nbsp;Do you like it?</span></h3>

	    <div class="inside" style="display: block;">
	        <img src="<?php 
            echo $url_plugin;
            ?>
icon_coffee.png" alt="buy me a coffee" style=" margin: 5px; float:left;">
	        <p>Hi! we are <a href="https://twitter.com/fjcarazo" target="_blank" title="Javier Carazo">Javier Carazo</a> and <a href="https://twitter.com/ahornero" target="_blank" title="Alberto Hornero">Alberto Hornero</a>  from <a href="http://codection.com">Codection</a>, developers of this plugin.</p>
	        <p>We have been spending many hours to develop this plugin. <br>If you like and use this plugin, you can <strong>buy us a cup of coffee</strong>.</p>
	        <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
				<input type="hidden" name="cmd" value="_s-xclick">
				<input type="hidden" name="hosted_button_id" value="QPYVWKJG4HDGG">
				<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
				<img alt="" border="0" src="https://www.paypalobjects.com/es_ES/i/scr/pixel.gif" width="1" height="1">
			</form>
	        <div style="clear:both;"></div>
	    </div>
	</div>

	<?php 
            break;
            ?>

	<?php 
        case 'help':
            ?>

	<div class="postbox">
	    <h3 class="hndle"><span>&nbsp;Need help with WordPress or WooCommerce?</span></h3>

	    <div class="inside" style="display: block;">
	        <p>Hi! we are <a href="https://twitter.com/fjcarazo" target="_blank" title="Javier Carazo">Javier Carazo</a> and <a href="https://twitter.com/ahornero" target="_blank" title="Alberto Hornero">Alberto Hornero</a>  from <a href="http://codection.com">Codection</a>, developers of this plugin.</p>
	        <p>We work everyday with WordPress and WooCommerce, if you need help hire us, send us a message to <a href="mailto:contacto@codection.com">contacto@codection.com</a>.</p>
	        <div style="clear:both;"></div>
	    </div>
	</div>

	<?php 
            break;
    }
}
 /**
  * @group save_xprofile_group_name
  */
 public function test_save_xprofile_group_name()
 {
     $g1 = $this->factory->xprofile_group->create(array('name' => "Test ' Name"));
     $e1 = new BP_XProfile_Group($g1);
     $e1->save();
     wp_cache_delete($g1, 'bp_xprofile_groups');
     $e2 = new BP_XProfile_Group($g1);
     $this->assertSame($e1->name, $e2->name);
 }
 /**
  * field_group_id_from_name( $group_name )
  *
  * Searches for a profile field group by it's name
  *
  * @param String $group_name the name of the field group to be found.
  * @return Int $group_id the id of the found field group
  */
 function field_group_id_from_name($group_name)
 {
     $group_id = null;
     $groups = BP_XProfile_Group::get();
     foreach ($groups as $g) {
         if ($g->name == $group_name) {
             $group_id = $g->id;
         }
     }
     return $group_id;
 }
/**
 * Handles the deletion of profile data groups.
 *
 * @param int $group_id ID of the group to delete.
 */
function xprofile_admin_delete_group($group_id)
{
    global $message, $type;
    $group = new BP_XProfile_Group($group_id);
    if (!$group->delete()) {
        $message = __('There was an error deleting the group. Please try again.', 'buddypress');
        $type = 'error';
    } else {
        $message = __('The group was deleted successfully.', 'buddypress');
        $type = 'success';
        /**
         * Fires at the end of group deletion process, if successful.
         *
         * @since 1.0.0
         *
         * @param BP_XProfile_Group $group Current BP_XProfile_Group object.
         */
        do_action('xprofile_groups_deleted_group', $group);
    }
    unset($_GET['mode']);
    xprofile_admin($message, $type);
}
 public function build_field_dd($current_field, $selected_field_id)
 {
     $groups = BP_XProfile_Group::get(array('fetch_fields' => true));
     $html = '';
     foreach ($groups as $group) {
         //if there are no fields in this group, no need to proceed further
         if (empty($group->fields)) {
             continue;
         }
         $html .= "<option value='0'> " . _x('Select Field', 'Fild selection title in admin', 'conditional-profile-fields-for-bp') . "</option>";
         $html .= "<optgroup label ='{ {$group->name} }'>";
         foreach ($group->fields as $field) {
             //can not have condition for itself
             if ($field->id == $current_field->id) {
                 continue;
             }
             $field = new BP_XProfile_Field($field->id, false, false);
             // $field->type_obj->supports_options;
             //$field->type_obj->supports_multiple_defaults;
             $html .= "<option value='{$field->id}'" . selected($field->id, $selected_field_id, false) . " >{$field->name}</option>";
             if ($field->type_obj->supports_options) {
                 $this->fields_info['field_' . $field->id]['type'] = 'multi';
                 $children = $field->get_children();
                 $this->fields_info['field_' . $field->id]['options'] = $children;
                 //get all children and we will render the view to select one of these children
             } else {
                 $this->fields_info['field_' . $field->id]['type'] = 'single';
             }
             //now, let us build an optgroup
         }
         $html .= "</optgroup>";
         echo $html;
         //$this->fields_info[]
     }
 }
예제 #16
0
/**
 * Handles all actions for the admin area for creating, editing and deleting
 * profile groups and fields.
 */
function wc4bp_xprofile_tabs($message = '', $type = 'error')
{
    $groups = BP_XProfile_Group::get(array('fetch_fields' => true));
    ?>

    <div id="tabs">
        <ul id="field-group-tabs" class="nav tabs" style="display: block;">

            <?php 
    if (!empty($groups)) {
        foreach ($groups as $group) {
            ?>
                    <li id="group_<?php 
            echo $group->id;
            ?>
"><a href="#tabs-<?php 
            echo $group->id;
            ?>
" class="ui-tab"><?php 
            echo esc_attr($group->name);
            if (!$group->can_delete) {
                ?>
 <?php 
                _e('(Primary)', 'wc4bp');
            }
            ?>
</a></li>

            <?php 
        }
    }
    ?>

        </ul>

        <?php 
    if (!empty($groups)) {
        foreach ($groups as $group) {
            ?>

            <div id="tabs-<?php 
            echo $group->id;
            ?>
" class="tab-wrapper">

                <?php 
            if ($group->name == 'Billing Address' || $group->name == 'Shipping Address') {
                ?>
                    <h3><?php 
                echo $group->name;
                ?>
 WooCommerce fields are already in the checkout and get synced with BuddyPress.</h3>
                <?php 
            }
            ?>

                <fieldset id="<?php 
            echo $group->id;
            ?>
" class="field-group">

                    <?php 
            if ($group->description) {
                ?>

                        <legend><?php 
                echo esc_attr($group->description);
                ?>
</legend>

                    <?php 
            }
            if (!empty($group->fields)) {
                foreach ($group->fields as $field) {
                    // Load the field
                    $field = new BP_XProfile_Field($field->id);
                    $class = '';
                    if (!$field->can_delete) {
                        $class = ' core nodrag';
                    }
                    /* This function handles the WYSIWYG profile field
                     * display for the xprofile admin setup screen
                     */
                    buddyforms_xprofile_admin_field($field, $group, $class);
                }
                // end for
            } else {
                // !$group->fields
                ?>

                        <p class="nodrag nofields"><?php 
                _e('There are no fields in this group.', 'wc4bp');
                ?>
</p>

                    <?php 
            }
            // end $group->fields
            ?>

                </fieldset>
            </div>

        <?php 
        }
    } else {
        ?>

            <div id="message" class="error"><p><?php 
        _e('You have no groups.', 'wc4bp');
        ?>
</p></div>
            <p><a href="users.php?page=bp-profile-setup&amp;mode=add_group"><?php 
        _e('Add New Group', 'wc4bp');
        ?>
</a></p>

        <?php 
    }
    ?>

    </div>
<?php 
}
예제 #17
0
function xprofile_delete_field_group( $field_group_id ) {
	$field_group = new BP_XProfile_Group( $field_group_id );
	return $field_group->delete();
}
예제 #18
0
 function __construct($user_id, $profile_group_id, $hide_empty_groups = false, $fetch_fields = false, $fetch_field_data = false, $exclude_groups = false, $exclude_fields = false, $hide_empty_fields = false)
 {
     $this->groups = BP_XProfile_Group::get(array('profile_group_id' => $profile_group_id, 'user_id' => $user_id, 'hide_empty_groups' => $hide_empty_groups, 'hide_empty_fields' => $hide_empty_fields, 'fetch_fields' => $fetch_fields, 'fetch_field_data' => $fetch_field_data, 'exclude_groups' => $exclude_groups, 'exclude_fields' => $exclude_fields));
     $this->group_count = count($this->groups);
     $this->user_id = $user_id;
 }
 /**
  * Returns a list with all known user profile fields.
  *
  * @since  1.0.1.0
  * @return array
  */
 public static function list_fields()
 {
     static $Profile_Fields = null;
     if (null === $Profile_Fields) {
         $Profile_Fields = array('username' => array('label' => __('Username', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'default_reg' => 'required', 'allowed_reg' => array('off', 'required'), 'allowed_edit' => array('off', 'readonly')), 'first_name' => array('label' => __('First Name', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'default_reg' => 'optional', 'default_edit' => 'optional'), 'last_name' => array('label' => __('Last Name', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'default_reg' => 'optional', 'default_edit' => 'optional'), 'nickname' => array('label' => __('Nickname', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_TEXT), 'display_name' => array('label' => __('Display As', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_TEXT), 'email' => array('label' => __('Email', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_EMAIL, 'default_reg' => 'required', 'default_edit' => 'required', 'allowed_reg' => array('required'), 'allowed_edit' => array('required')), 'website' => array('label' => __('Website', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_TEXT), 'description' => array('label' => __('Biographic Info', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_TEXT_AREA), 'password' => array('label' => __('Password', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_PASSWORD, 'default_reg' => 'required', 'default_edit' => 'optional', 'allowed_reg' => array('off', 'required'), 'allowed_edit' => array('off', 'optional')), 'password2' => array('label' => __('Password Confirmation', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_PASSWORD, 'default_reg' => 'required', 'default_edit' => 'optional', 'allowed_reg' => array('off', 'required'), 'allowed_edit' => array('off', 'optional')));
         if (is_user_logged_in()) {
             $member = MS_Model_Member::get_current_member();
             $user = $member->get_user();
             $Profile_Fields['username']['value'] = $member->username;
             $Profile_Fields['first_name']['value'] = $member->first_name;
             $Profile_Fields['last_name']['value'] = $member->last_name;
             $Profile_Fields['email']['value'] = $member->email;
             $Profile_Fields['nickname']['value'] = $member->get_meta('nickname');
             $Profile_Fields['display_name']['value'] = $user->display_name;
             $Profile_Fields['website']['value'] = $user->user_url;
             $Profile_Fields['description']['value'] = $member->get_meta('description');
         }
         if (function_exists('bp_is_active') && bp_is_active('xprofile')) {
             $profile_groups = BP_XProfile_Group::get(array('fetch_fields' => true));
             $profile_groups = lib2()->array->get($profile_groups);
             foreach ($profile_groups as $profile_group) {
                 $fields = lib2()->array->get($profile_group->fields);
                 foreach ($fields as $field) {
                     $Profile_Fields['xprofile_' . $field->id] = array('label' => $field->name);
                 }
             }
         }
     }
     return $Profile_Fields;
 }
예제 #20
0
/**
 * Handles the deletion of profile data groups.
 */
function xprofile_admin_delete_group($group_id)
{
    global $message, $type;
    $group = new BP_XProfile_Group($group_id);
    if (!$group->delete()) {
        $message = __('There was an error deleting the group. Please try again', 'buddypress');
        $type = 'error';
    } else {
        $message = __('The group was deleted successfully.', 'buddypress');
        $type = 'success';
        do_action('xprofile_groups_deleted_group', $group);
    }
    unset($_GET['mode']);
    xprofile_admin($message, $type);
}
예제 #21
0
    function admin_page()
    {
        // Pull up the existing values
        $settings = bp_get_option('bp_smp_settings');
        $defaults = array('display' => array('inline'), 'label' => __('Follow me online: ', 'bp-smp'), 'inline_position' => 'top', 'replace_field' => '');
        $r = wp_parse_args($settings, $defaults);
        extract($r);
        ?>

		<div class="wrap">
			<?php 
        screen_icon('buddypress');
        ?>

			<h2><?php 
        _e('BuddyPress Social Media Profiles', 'buddypress');
        ?>
</h2>

			<form method="post" action="">

			<table class="form-table">

				<tr>
					<th scope="row">
						<?php 
        _e('Display location', 'bp-smp');
        ?>
					</th>

					<td>
						<input type="checkbox" name="bp_smp[display][]" value="header" <?php 
        if (in_array('header', $display)) {
            ?>
checked="checked"<?php 
        }
        ?>
 /> <?php 
        _e('Headers', 'bp-smp');
        ?>
						<p class="description"><?php 
        _e('Fields marked as Social Media fields will be displayed in each user\'s header', 'bp-smp');
        ?>
</p>

						<input type="checkbox" name="bp_smp[display][]" value="inline" id="bp-smp-display-inline" <?php 
        if (in_array('inline', $display)) {
            ?>
checked="checked"<?php 
        }
        ?>
/> <?php 
        _e('Profiles', 'bp-smp');
        ?>

						<div id="inline-opts"<?php 
        if (!in_array('inline', $display)) {
            ?>
 style="display:none;"<?php 
        }
        ?>
>
							<label for="bp_smp[inline_position]"><?php 
        _e('Position:', 'bp-smp');
        ?>
</label>

							<ul>
								<li><input type="radio" name="bp_smp[inline_position]" value="top" <?php 
        checked($inline_position, 'top');
        ?>
/> <?php 
        _e('Top', 'bp-smp');
        ?>
 - <span class="description"><?php 
        _e('Social media profiles will be displayed at the top of profiles', 'bp-smp');
        ?>
</span></li>
								<li><input type="radio" name="bp_smp[inline_position]" value="bottom" <?php 
        checked($inline_position, 'bottom');
        ?>
/> <?php 
        _e('Bottom', 'bp-smp');
        ?>
 - <span class="description"><?php 
        _e('Social media profiles will be displayed at the bottom of profiles', 'bp-smp');
        ?>
</span></li>
								<li>
									<input type="radio" name="bp_smp[inline_position]" value="replace" <?php 
        checked($inline_position, 'replace');
        ?>
 id="inline-replace" /> <?php 
        _e('Replace profile field', 'bp-smp');
        ?>

									<?php 
        $groups = BP_XProfile_Group::get(array('fetch_fields' => true));
        ?>

									<?php 
        if (!empty($groups)) {
            ?>

									<select name="bp_smp[replace_field]" id="inline-replace-field">

									<option value="" <?php 
            checked($replace_field, '');
            ?>
><?php 
            _e('- Select One -', 'bp-smp');
            ?>
</option>

									<?php 
            foreach ($groups as $group) {
                foreach ($group->fields as $field) {
                    ?>
										<option value="<?php 
                    echo esc_attr($field->id);
                    ?>
" <?php 
                    selected($replace_field, $field->id);
                    ?>
><?php 
                    echo esc_html($field->name);
                    ?>
</option>
									<?php 
                }
            }
            ?>

									</select>

									<span class="description"><?php 
            _e('Social media profiles will <strong>replace</strong> one of your existing profile fields.', 'bp-smp');
            ?>
</span>

									<?php 
        }
        ?>
								</li>
							</ul>
						</div>

						<p class="description"><?php 
        _e('Fields marked as Social Media fields will be displayed as part of each user\'s public profile.', 'bp-smp');
        ?>
</p>
					</td>
				</tr>

				<tr>
					<th scope="row">
						<?php 
        _e('Label', 'bp-smp');
        ?>
					</th>

					<td>
						<input type="text" name="bp_smp[label]" value="<?php 
        echo esc_attr($label);
        ?>
" />
						<p class="description"><?php 
        _e('Text that will precede the social media fields on the public profile or user header.', 'bp-smp');
        ?>
</p>

					</td>
				</tr>

			</table>

			<?php 
        wp_nonce_field('bp_smp');
        ?>
			<input type="submit" name="bp-smp-submit" class="button-primary" value="<?php 
        _e("Save Settings", 'bp-smp');
        ?>
" />

			</form>
		</div>

		<?php 
    }
예제 #22
0
function xprofile_update_field_group_position($field_group_id, $position)
{
    return BP_XProfile_Group::update_position($field_group_id, $position);
}
/**
 * Handles the adding or editing of profile field data for a user.
 */
function xprofile_admin_manage_field($group_id, $field_id = null)
{
    global $bp, $wpdb, $message, $groups;
    $field = new BP_XProfile_Field($field_id);
    $field->group_id = $group_id;
    if (isset($_POST['saveField'])) {
        if (BP_XProfile_Field::admin_validate()) {
            $field->name = wp_filter_kses($_POST['title']);
            $field->description = !empty($_POST['description']) ? wp_filter_kses($_POST['description']) : '';
            $field->is_required = wp_filter_kses($_POST['required']);
            $field->type = wp_filter_kses($_POST['fieldtype']);
            if (!empty($_POST["sort_order_{$field->type}"])) {
                $field->order_by = wp_filter_kses($_POST["sort_order_{$field->type}"]);
            }
            $field->field_order = $wpdb->get_var($wpdb->prepare("SELECT field_order FROM {$bp->profile->table_name_fields} WHERE id = %d", $field_id));
            if (!$field->field_order) {
                $field->field_order = (int) $wpdb->get_var($wpdb->prepare("SELECT max(field_order) FROM {$bp->profile->table_name_fields} WHERE group_id = %d", $group_id));
                $field->field_order++;
            }
            // For new profile fields, set the $field_id. For existing profile fields,
            // this will overwrite $field_id with the same value.
            $field_id = $field->save();
            if (!$field_id) {
                $message = __('There was an error saving the field. Please try again', 'buddypress');
                $type = 'error';
                unset($_GET['mode']);
                xprofile_admin($message, $type);
            } else {
                $message = __('The field was saved successfully.', 'buddypress');
                $type = 'success';
                if (1 == $field_id) {
                    bp_update_option('bp-xprofile-fullname-field-name', $field->name);
                }
                if (!empty($_POST['default-visibility'])) {
                    bp_xprofile_update_field_meta($field_id, 'default_visibility', $_POST['default-visibility']);
                }
                if (!empty($_POST['allow-custom-visibility'])) {
                    bp_xprofile_update_field_meta($field_id, 'allow_custom_visibility', $_POST['allow-custom-visibility']);
                }
                unset($_GET['mode']);
                do_action('xprofile_fields_saved_field', $field);
                $groups = BP_XProfile_Group::get();
                xprofile_admin($message, $type);
            }
        } else {
            $field->render_admin_form($message);
        }
    } else {
        $field->render_admin_form();
    }
}
예제 #24
0
function xprofile_admin_manage_field($group_id, $field_id = null)
{
    global $bp, $nxtdb, $message, $groups;
    $field = new BP_XProfile_Field($field_id);
    $field->group_id = $group_id;
    if (isset($_POST['saveField'])) {
        if (BP_XProfile_Field::admin_validate()) {
            $field->name = nxt_filter_kses($_POST['title']);
            $field->description = !empty($_POST['description']) ? nxt_filter_kses($_POST['description']) : '';
            $field->is_required = nxt_filter_kses($_POST['required']);
            $field->type = nxt_filter_kses($_POST['fieldtype']);
            if (!empty($_POST["sort_order_{$field->type}"])) {
                $field->order_by = nxt_filter_kses($_POST["sort_order_{$field->type}"]);
            }
            $field->field_order = $nxtdb->get_var($nxtdb->prepare("SELECT field_order FROM {$bp->profile->table_name_fields} WHERE id = %d", $field_id));
            if (!$field->field_order) {
                $field->field_order = (int) $nxtdb->get_var($nxtdb->prepare("SELECT max(field_order) FROM {$bp->profile->table_name_fields} WHERE group_id = %d", $group_id));
                $field->field_order++;
            }
            if (!$field->save()) {
                $message = __('There was an error saving the field. Please try again', 'buddypress');
                $type = 'error';
                unset($_GET['mode']);
                xprofile_admin($message, $type);
            } else {
                $message = __('The field was saved successfully.', 'buddypress');
                $type = 'success';
                if (1 == $field_id) {
                    bp_update_option('bp-xprofile-fullname-field-name', $field->name);
                }
                unset($_GET['mode']);
                do_action('xprofile_fields_saved_field', $field);
                $groups = BP_XProfile_Group::get();
                xprofile_admin($message, $type);
            }
        } else {
            $field->render_admin_form($message);
        }
    } else {
        $field->render_admin_form();
    }
}
예제 #25
0
function xprofile_admin_manage_field($group_id, $field_id = null)
{
    global $message, $groups;
    $field = new BP_XProfile_Field($field_id);
    $field->group_id = $group_id;
    if (isset($_POST['saveField'])) {
        if (BP_XProfile_Field::admin_validate($_POST)) {
            $field->name = wp_filter_kses($_POST['title']);
            $field->desc = wp_filter_kses($_POST['description']);
            $field->is_required = wp_filter_kses($_POST['required']);
            $field->is_public = wp_filter_kses($_POST['public']);
            $field->type = wp_filter_kses($_POST['fieldtype']);
            $field->order_by = wp_filter_kses($_POST["sort_order_{$field->type}"]);
            if (!$field->save()) {
                $message = __('There was an error saving the field. Please try again', 'buddypress');
                $type = 'error';
                unset($_GET['mode']);
                xprofile_admin($message, $type);
            } else {
                $message = __('The field was saved successfully.', 'buddypress');
                $type = 'success';
                unset($_GET['mode']);
                do_action('xprofile_fields_saved_field', $field);
                $groups = BP_XProfile_Group::get_all();
                xprofile_admin($message, $type);
            }
        } else {
            $field->render_admin_form($message);
        }
    } else {
        $field->render_admin_form();
    }
}
예제 #26
0
/**
 * Fetch an array of the xprofile fields that a given user has marked with certain visibility levels
 *
 * @since BuddyPress (1.6.0)
 * @see bp_xprofile_get_hidden_fields_for_user()
 *
 * @param int $user_id The id of the profile owner
 * @param array $levels An array of visibility levels ('public', 'friends', 'loggedin', 'adminsonly' etc) to be
 *    checked against
 * @return array $field_ids The fields that match the requested visibility levels for the given user
 */
function bp_xprofile_get_fields_by_visibility_levels($user_id, $levels = array())
{
    if (!is_array($levels)) {
        $levels = (array) $levels;
    }
    $user_visibility_levels = bp_get_user_meta($user_id, 'bp_xprofile_visibility_levels', true);
    // Parse the user-provided visibility levels with the default levels, which may take
    // precedence
    $default_visibility_levels = BP_XProfile_Group::fetch_default_visibility_levels();
    foreach ((array) $default_visibility_levels as $d_field_id => $defaults) {
        // If the admin has forbidden custom visibility levels for this field, replace
        // the user-provided setting with the default specified by the admin
        if (isset($defaults['allow_custom']) && isset($defaults['default']) && 'disabled' == $defaults['allow_custom']) {
            $user_visibility_levels[$d_field_id] = $defaults['default'];
        }
    }
    $field_ids = array();
    foreach ((array) $user_visibility_levels as $field_id => $field_visibility) {
        if (in_array($field_visibility, $levels)) {
            $field_ids[] = $field_id;
        }
    }
    // Never allow the fullname field to be excluded
    if (in_array(1, $field_ids)) {
        $key = array_search(1, $field_ids);
        unset($field_ids[$key]);
    }
    return $field_ids;
}
예제 #27
0
                </tr>
            </tbody>
        </table>

        <h3><?php _e("User Signature: BuddyPress Profile Field Group", "gd-bbpress-tools"); ?></h3>
        <p><?php _e("Select group where the signature editor will be displayed.", "gd-bbpress-tools"); ?></p>
        <table class="form-table">
            <tbody>
                <tr valign="top">
                    <th scope="row"><label><?php _e("Field Group", "gd-bbpress-tools"); ?></label></th>
                    <td>
                        <?php

                        $groups = array();
                        if (class_exists('BP_XProfile_Group')) {
                            $raw = BP_XProfile_Group::get(array('fetch_fields' => false));

                            foreach ($raw as $group) {
                                $groups[$group->id] = $group->name;
                            }
                        } else {
                            $groups = array('1' => __("Base", "gd-bbpress-tools"));
                        }

                        ?>
                        <select name="signature_buddypress_profile_group" class="regular-text">
                            <?php

                            foreach ($groups as $key => $name) {
                                $selected = $options['signature_buddypress_profile_group'] == $key ? ' selected="selected"' : '';
                                echo '<option value="'.$key.'"'.$selected.'>'.$name.'</option>';
function buatp_profile_groups_exclude_from_tab()
{
    global $bp, $profile_template;
    $settings_profile_data = get_option('buatp_profile_data_setting', false);
    if (!$settings_profile_data) {
        return false;
    }
    $user_id = $bp->displayed_user->id;
    if (current_user_can('create_users')) {
        return;
    }
    $user_type = buatp_get_user_type($user_id);
    $type_id = buatp_get_field_id_by_name($user_type);
    $excluded = $settings_profile_data['buatp_exclude_groups_for_' . $type_id];
    if (!$excluded) {
        return;
    }
    $groups = BP_XProfile_Group::get(array('fetch_fields' => true));
    foreach ($groups as $key => $profile_group) {
        if (in_array($profile_group->id, (array) $excluded)) {
            unset($groups[$key]);
        }
    }
    $groups = array_values($groups);
    wp_cache_set('xprofile_groups_inc_empty', $groups, 'bp');
}
 /**
  * Builds the condition details
  */
 public function build_conditions()
 {
     $groups = BP_XProfile_Group::get(array('fetch_fields' => true));
     foreach ($groups as $group) {
         foreach ($group->fields as $field) {
             $this->fields['field_' . $field->id]['data'] = $field;
             $field = new BP_XProfile_Field($field->id);
             //READ IT PLEASE
             //Now, I need type to handle the event binding on client side
             ////the problem is there are inconsistency in the way id/class are applied on generated view, That's why I need type info
             //BuddyPress does not give explicit type, except for the class name,
             // now, It is bad but I am stil going to do it anyway
             //Can we improve this in future?
             $class_name = explode('_', get_class($field->type_obj));
             $class_name = strtolower(array_pop($class_name));
             $this->fields['field_' . $field->id]['type'] = $class_name;
             //we got type+data
             //let us get the children
             $children = $field->get_children();
             if (!empty($children)) {
                 $this->fields['field_' . $field->id]['children'] = $children;
             }
             $related_id = $this->get_related_field_id($field->id);
             //if this field has no condition set, let us not worry
             if (!$related_id) {
                 continue;
             }
             //if we have condition set on this field, let us get info
             $this->conditional_fields['field_' . $related_id]['conditions'][] = $this->get_field_condition($field->id);
         }
     }
     $this->data = $this->get_data();
 }