Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'group_id'

Viewing 25 results - 226 through 250 (of 567 total)
  • Author
    Search Results
  • #232741
    modemlooper
    Moderator

    find the template file edit.php in members/single/profile
    locate
    if ( bp_has_profile( 'profile_group_id=' . bp_get_current_profile_group_id() ) ) :
    change to
    if ( bp_has_profile( 'profile_group_id=' . bp_get_current_profile_group_id() . bp_custom_filter_xprofile_fields() ) ) :

    then add your function for field IDs

    function bp_custom_filter_xprofile_fields() {
    
    	$member_type = bp_get_member_type( bp_displayed_user_id() );
    
    	if ( 'member_type_here' === $member_type  ) {
    		return '&exclude_fields=3,5,9' ) );
    	}
    }

    you will have to find the IDs of the profile fields

    #231761
    sk_tamilan
    Participant

    @modemlooper The only problem is i am updating the content with the Post ID and thumbnail of the post for activity prior to submitting it, is there any other way of doing is ?

    
    add_action('bp_activity_before_save', 'rewards_activity_content', 3);
    
    add_action('publish_rewards', 'groups_rewards_activity',4,1);
    
    /* Filter for content for post type reward before saved to database */
    function rewards_activity_content($activity){
    
        global $post;
        global $bp;
    
        if ($post->post_type == 'rewards') {
    
            $activity_id = (int) $activity->id;
            $post_id = (int) $activity->secondary_item_id;
            $user_id = (int) $activity->user_id;
            
    
            $post_type = get_post_type( $post_id );
            $thumbnail = get_the_post_thumbnail($post_id);
            $post_permalink = get_permalink($post_id);
            $title = get_the_title($post_id);
    
      
    
            $activity_content  = "<div class='post-id'>The post ID : {$post_id}</div>\n";
            $activity_content .= "<div class='thumbnail'>{$thumbnail}</div>\n";
            $activity->content = $activity_content;
    
            $group_id = (int) BP_Groups_Group::group_exists($field_group[0]);  //working :)
    
            
        
            $bp->groups->current_group = groups_get_group( array( 'group_id' => $group_id ) );
    
            $groups_activity_action  = sprintf( __( '%1$s posted a reward %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink( $user_id ),'<a href="' . $post_permalink . '">' . $post->post_title . '</a>' ,'<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' );
    
            $groups_args = array(
                'action'            => apply_filters( 'groups_activity_new_update_action',  $groups_activity_action  ),
                'content'           => apply_filters( 'groups_activity_new_update_content', $activity_content ),
                'component'         => 'groups',
                'type'              => 'activity_update',
                'type'              => 'new_forum_post',
                'primary_link'      => $post_permalink,
                'secondary_item_id' => $post_id,
                'item_id'           => $group_id,
                'user_id'           => $user_id,
            ); //all of groups_args array value is being populated
    
            //do_action( 'bp_activity_add', $groups_args ); //not working
            do_action( 'groups_rewards_activity', $groups_args );
    
        }
    
        return $activity; 
    }
    
    function groups_rewards_activity($groups_args){
    
       $id = bp_activity_add($groups_args);
    
       return $id;
    
    }
    thomasklosinsky
    Participant

    for everyone who needs it too:

    $user_id = bp_loggedin_user_id();
    $group_ids = $wpdb->get_col($wpdb->prepare(“SELECT group_id FROM {$wpdb->prefix}bp_groups_members WHERE user_id = %d”,$user_id),0);
    foreach ($group_ids as $group_id )
    {
    $category_ids .= “,”.implode(bcg_get_categories($group_id));
    };
    $category_ids = substr($category_ids, 1);

    That’s all.

    Add query_posts(“cat=$category_ids”); and you are good to go.

    #230864
    ARCangelGIRL
    Participant

    @brgweb In plugins/buddypress-activity-plus/js/bpfb_interface.js in line ~49-50 I’m passing categories drop down form

    $('.bpfb_preview_container').empty().html(data);
    $('.bpfb_action_container').html('  <div id="category"> <select name="video_category"><option value="category1">Category1</option>........ 

    In line ~435

    $(document).on('click', '#bpfb_submit', function () {
    		var params = _bpfbActiveHandler.get();
    		var group_id = $('#whats-new-post-in').length ? $('#whats-new-post-in').val() : 0;
    		var category = $('#category').val();
    		var subcategory = $('#subcategory').val();
    		$.post(ajaxurl, {
    			"action": "bpfb_update_activity_contents",
    			"data": params,
    			"content": $text.val(),
    			"group_id": group_id,
    			"category": category,
    			"subcategory": subcategory
    

    And then in plugins/buddypress-activity-plus/lib/class_bpfb_binder.php in line ~328

    $query='UPDATE wp_bp_activity SET video_category="'. $_POST['category'].'", video_subcategory="'. $_POST['subcategory'].'" WHERE id=' . $aid; 
    		$dummy=mysql_query($query);

    I’ll try with the code you provide to see if it’s working.

    #230835
    Ricardo Gonçalves
    Participant

    This is the code I added at line 278 in /wp-content/plugins/buddypress-activity-plus/lib/class_bpfb_binder.php to create the action. The credit for this code is @Juanma in WordPress.org forum. (couldn’t find the original thread). In this case I’m creating an action for images upload.

    function ajax_update_activity_contents () {
      $bpfb_code = $activity = '';
      $aid = 0;
      $codec = new BpfbCodec;
      if (@$_POST['data']['bpfb_photos']) {
        $images = $this->move_images($_POST['data']['bpfb_photos']);
        $bpfb_code = $codec->create_images_tag($images);
        $type = 'bpfb_share_wall_photos';
      }
    
      $bpfb_code = apply_filters('bpfb_code_before_save', $bpfb_code);
    
      // All done creating tags. Now, save the code
      $gid = (int)@$_POST['group_id'];
      if ($bpfb_code) {
        global $bp;
        $content = @$_POST['content'] . "\n" . $bpfb_code;
        $content = apply_filters('bp_activity_post_update_content', $content);
        $user_id = $bp->loggedin_user->id;
        $userlink = bp_core_get_userlink( $user_id );
    
        $author = bp_core_get_userlink( $author_id );
        $activity_url = bp_activity_get_permalink( $item_id );
    
        $aid = $gid ?
          groups_post_update(array('conte nt' => $content, 'group_id' => $gid)) : 
          bp_activity_add(
            array(
              'action' => apply_filters( 'activity_update', sprintf( __( '%s shared a link', 'buddypress' ), $userlink ), $user_id ),
              'content' => $content,
              'component' => 'activity',
              'type' => $type,
              'user_id' => $user_id
            )
          );
          if ($aid) {
    			ob_start();
    			if ( bp_has_activities ( 'include=' . $aid ) ) {
    				while ( bp_activities() ) {
    					bp_the_activity();
    					if (function_exists('bp_locate_template')) bp_locate_template( array( 'activity/entry.php' ), true );
    					else locate_template( array( 'activity/entry.php' ), true );
    				}
    			}
    			$activity = ob_get_clean();
    		}
    		header('Content-type: application/json');
    		echo json_encode(array(
    			'code' => $bpfb_code,
    			'id' => $aid,
    			'activity' => $activity,
    		));
    		exit();
    	}
    }

    And this is the code that works for activity stream. It shows just the activities with this action, but when you click the ‘load more’ button it loads the regular stream.
    <?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ) . '&action=bpfb_share_wall_photos') ) : ?>

    #230246
    shanebp
    Moderator

    As I pointed out above, you should use bp_get_group_member_name() not bp_group_member_name().
    The latter will echo out the name. The former will return it as a variable.

    Check your error logs.
    You need to be on a group page to use while ( bp_group_members() )
    Otherwise you need to precede it with if ( bp_group_has_members( 'group_id=15' ) ) :

    #230166

    In reply to: Groups of Friends list

    shanebp
    Moderator

    Maybe there’s an easier way, but I’d do this…

    Use friends_get_friend_user_ids(...) to get the ids of the logged-in user’s friends.

    Pass each friend id thru groups_get_groups in user_id field.

    Use groups_is_user_creator( $user_id, $group_id ) to determine if the friend was the creator of each group.

    #229769
    Tunn
    Participant

    This is what I use now. Try it:

    /**
     * Show content only to group members
     * Author: Iurie Malai
     */
    
    add_shortcode( 'group', 'group_check_shortcode' );
    // usage: [group id = YOUR_GROUP_ID_HERE] content [/group]
    
    function group_check_shortcode( $atts, $content = null ) {
    	extract(shortcode_atts(array( 'id' => '', ), $atts));
    	if( groups_is_user_member( bp_loggedin_user_id(), $id ) ) { return do_shortcode( $content ); }
    	if( $id == 1 ) {
    		return '<p>This will be seen only by logged in members of group with id = 1. In my case this is the group with all members of my site</p>';
    	} else { 
    		$group = groups_get_group( array( 'group_id' => $id ) );
    		//Put your User Groups Page Slug in the next code row.
    		//Usually this is "groups", but in my case it is different.
    		$url = home_url( $path = 'USER_GROUPS_PAGE_SLUG_HERE/' . $group->slug . '/', $scheme = relative );
    		return '<p>This will be seen only by logged in members of group with id that you specified by shortcode in your page or post. This will show the group name: <a href="' . $url . '">' .  $group->name . '</a>.</p>' ; }
    } /*---------------------------------------------------------*/
    
    #228952
    Jimtrim
    Participant

    I’m doing a call to bp_register_group_extension( 'EP_Group_Tasks' ); with a class I want to extend the BP_Group_Extensionclass. Full code of the file:

    <?php
    /**
     * User: jimtrim
     * Date: 11/11/14
     * Time: 09:17
     */
    
    if ( class_exists( 'BP_Group_Extension' ) ) {
    
    	class BP_Group_Tasks extends BP_Group_Extension{
    		/**
    		 * Here you can see more customization of the config options
    		 */
    		function __construct() {
    			$args = array(
    				'slug'              => 'tasks',
    				'name'              => __('Tasks', 'revyweb'),
    				'nav_item_position' => 90,
    				'screens'           => array(
    					'create' => array(
    						'name'        => __('Create task', 'revyweb'),
    						'submit_text' => __('Save task', 'revyweb')
    					),
    					'edit' => array(
    						'name'        => __('Edit task', 'revyweb'),
    						'submit_text' => __('Save task', 'revyweb')
    					),
    					'admin' => array(
    						'name'        => __('Administer task', 'revyweb'),
    						'submit_text' => __('Save task', 'revyweb')
    					),
    				),
    			);
    			parent::init( $args );
    		}
    
    		function display() {
    			//get_template_part( 'buddypress/custom/view', 'tasks' );
    			$group_id = bp_get_group_id();
    			echo "GET READY FOR SOME TASKS";
    
    		}
    
    		public function settings_screen( $group_id = null ) {
    
    			//get_template_part( 'buddypress/custom/settings', 'tasks' );
    			$setting = groups_get_groupmeta( $group_id, 'task_name' );
    
    			?>
    				Save your task name here: <input type="text" name="task_name" value="<?php echo esc_attr( $setting ) ?>" />
    			<?php
    
    		}
    
    		function settings_screen_save( $group_id = NULL ) {
    			$setting = '';
    
    			if ( isset( $_POST['task_name'] ) ) {
    				$setting = $_POST['task_name'];
    			}
    
    			groups_update_groupmeta( $group_id, 'task_name', $setting );
    		}
    
    	}
    
    	bp_register_group_extension( 'EP_Group_Tasks' );
    
    } else {
    	$msg = "Class BP_Group_Extension not found for Revyweb_Personal";
    //	trigger_error($msg, E_USER_NOTICE);
    	echo $msg;
    }

    Edit: yes, User Groups are enabled, and I can display user groups on the frontend, but I can’t add my own BP_Group_Extention

    #228796
    jessy
    Participant

    Solved:
    Define $group_id = NULL in the functions where errors appear, like this:

    function settings_screen( $group_id = NULL )
    function settings_screen_save( $group_id = NULL )
    function create_screen( $group_id = NULL )
    #228731
    shanebp
    Moderator

    I’ve updated the codex page.
    Please use the updated examples.

    Note this addition$group_id = bp_get_group_id(); to function display()

    #228001
    mohammad-mursaleen
    Participant

    OK finally done with the function to get what I was looking for;

    /* to get total update counts by group id*/
    
    function get_total_updates_count($group_id){
    
    	global $wpdb;
     
    	$total_updates = $wpdb->get_var( "SELECT COUNT(*) FROM wp_bp_activity 
    					  WHERE component = 'groups' 
    					  AND   type = 'activity_update'
    					  AND   item_id = '$group_id' 
                                             ");
    									  
    	return $total_updates;
    }

    And to use in groups loop you can do as following;

    <?php echo get_total_updates_count(bp_get_group_id()); ?>

    Hope this would help someone in community.

    #227708

    In reply to: BP Group Extension API

    sbdm05
    Participant

    First, thank you very much for you quick reply!

    I’ve been trying to implement that but nothing happens.

    Could you please have a look at the code as I am really a beginner at this! Thank you so much!

    [edited – Please Use the ‘code’ button when including code.
    Or even better, use gist or pastebin and just share the link ]

    if ( class_exists( 'BP_Group_Extension' ) ) :
    	
    	class Group_Extension_Ville extends BP_Group_Extension {
    		
    		function __construct() {
    			$args = array(
    			'slug' => 'group-extension-ville',
    			'name' => 'ville',
    			);
    			parent::init( $args );
    		}
    		
    		
    		function display() {
    			$group_extension_ville = groups_get_groupmeta( $group_id, 'group_extension_ville' );
    			echo esc_attr( $group_extension_ville );
    		}
    		
    		
    		function settings_screen( $group_id ) {
    			$setting = groups_get_groupmeta( $group_id, 'group_extension_ville' );
    		
    		?>
    			Save your plugin setting here: <input type=”text” name='group_extension_ville_setting' value='<?php echo esc_attr( $setting ) ?>' />
    		<?php
    		}
    		
    		
    		function settings_screen_save( $group_id ) {
    			$setting = '';
    			
    			if ( isset( $_POST['group_extension_ville_setting'] ) ) {
    				$setting = $_POST['group_extension_ville_setting'];
    			}
    			
    			groups_update_groupmeta( $group_id, 'group_extension_ville_setting', $setting );
    		}
    	}
    	bp_register_group_extension( 'Group_Extension_Ville' );
    
    endif; // if ( class_exists( 'BP_Group_Extension' ) )
    #227704

    In reply to: BP Group Extension API

    shanebp
    Moderator

    Try:

    function display() {
         $town = groups_get_groupmeta( $group_id, 'town' );
         echo esc_attr( $town );
    }
    #224231
    robertosalemi
    Participant

    I resolved with this code:

    //GET INFORMATION GROUP
    if (!$group = groups_get_group( array( 'group_id' => $group_id ) ) )
    {
    	return false;
    }
    else 
    {
       $group_name = $group->name;
       $group_slug = $group->slug;
    }

    Thanks for all!

    #223412
    crina27
    Participant

    The quote typo appeared when I copied the functions.
    function bp_group_chat_format_notifications( $action, $item_id, $secondary_item_id, $total_items) {
    global $bp;

    switch ( $action ) {
    case ‘new_group_chat’:
    $group_id = $secondary_item_id;
    $group = new BP_Groups_Group( $group_id );
    $group_link = bp_get_group_permalink( $group );

    $groupSlug=groups_get_slug( $secondary_item_id);
    $url=home_url( $bp->groups->slug . ‘/’ .$groupSlug . ‘/group-chat’ );
    $return=’‘ . sprintf( __( ‘%s group broadcast invite!’, ‘group-chat’ ), $groupSlug ) . ‘‘;
    break;
    }
    do_action( ‘bp_group_chat_format_notifications’);
    return $return;

    }

    Which code button do I have to use?

    #214085

    In reply to: Directory

    shanebp
    Moderator

    Sounds like a checkboxes field in the ‘Base Group’ is what you want.

    Go to:
    /wp-admin/users.php?page=bp-profile-setup&group_id=1&mode=add_field

    Add a Field and select ‘checkboxes’ as the field type.

    #206284
    1a-spielwiese
    Participant

    For me also not:

    I tried it with

    Mitglieder-Kategorie (Team oder Fan?)

    instead of

    'name of your field'

    as well as with

    'Mitglieder-Kategorie (Team oder Fan?)'

    But my users can still change the values for this field. –

    I tried as well – already before and now again – this code of @noizeburger:

    //hide the user role select field in edit-screen to prevent changes after registration
    add_filter("xprofile_group_fields","bpdev_filter_profile_fields_by_usertype",10,2);
    function bpdev_filter_profile_fields_by_usertype($fields,$group_id){
    //only disable these fields on edit page
    if(!bp_is_profile_edit())
    return $fields;
    //please change it with the name of fields you don't want to allow editing
    $field_to_remove=array("User Role");
    $count=count($fields);
    $flds=array();
    for($i=0;$i<$count;$i++){
    if(in_array($fields[$i]->name,$field_to_remove))
    unset($fields[$i]);
    else
    $flds[]=$fields[$i];//doh, I did not remember a way to reset the index, so creating a new array
    }
    return $flds;
    }

    It works neither with

    "Mitglieder-Kategorie (Team oder Fan?)"

    nor with

    Mitglieder-Kategorie (Team oder Fan?)

    nor with:

    'Mitglieder-Kategorie (Team oder Fan?)'

    #203615
    1a-spielwiese
    Participant

    I found two more solutions:

    1st:

    a) The place of the field for determining the user role is depending on the plugins/wp-roles-at-registration/wp-roles-at-registration.php

    The relevant line of the original version of that file is:

    add_action('bp_after_signup_profile_fields', array($wp_rar_plugin, 'bp_choose_roles_registration_form'));

    I substituted there bp_after_signup_profile_fields by template_notices and now the field at issue is displayed not the end, rather at the beginning of my registration page:

    http://1a-spielwiese.de/registrieren/

    b)

    For creating the headline and the introductory text I made a second change within the same file. I changed the following section. The first and the last line of the quote is the original code, and the lines inbetween I inserted:

        <div class="register-section" id="user-role-section">
        
        <h4-a><?php _e( 'Benutzer/in/rolle', 'buddypress' ); ?></h4-a>
    
        <p><small><em>Entscheide Dich bitte als allererstes f&uuml;r eine der Benutzer/in/rollen "Team" oder "Fan" (bitte w&auml;hle nicht die Rolle "Subscriber"; diese Angabe soll noch gel&ouml;scht werden). In Abh&auml;ngigkeit von Deiner Antwort wirst Du nach Abschluss der Registrierung und wenn Du Dich das erste Mal bei 1a-Spielwiese einloggst und Dir Dein Profil ansiehst, die M&ouml;glichkeit haben, einige erg&auml;nzende rollenspezifische Profilangaben zu machen.</em></small></p>
    
        <label for="wp_rar_user_role"><?php echo $this->wp_rar_role_label; ?></label>

    2nd:

    As well I was able to integrate now not only the ‘base’-profile field group. For that it is neccessary to copy a long section of the buddypress register.php. This sections begins with:

    			<?php /***** Extra Profile Details ******/ ?>
    
    			<?php if ( bp_is_active( 'xprofile' ) ) : ?>
    
    				<?php do_action( 'bp_before_signup_profile_fields' ); ?>
    
    				<div class="register-section" id="profile-details-section">
    
    					<h4><?php _e( 'Profile Details', 'buddypress' ); ?></h4>
    
    					<?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?>
    
    					<?php if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( array( 'profile_group_id' => 1, 'fetch_field_data' => false ) ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>

    And it ends with:

    					<input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_field_ids(); ?>" />
    
    					<?php endwhile; endif; endif; ?>
    
    					<?php do_action( 'bp_signup_profile_fields' ); ?>
    
    				</div><!-- #profile-details-section -->
    
    			<?php endif; ?>

    The only two things, which are obligatory then:

    • You have to insert the entire copied section behind the last line of the original section.
    • And you have to change 'profile_group_id' => 1, into 'profile_group_id' => 2, (for adressing your second profile field group – and so on regarding the further profile field groups).

    Besides I changed the <h4>-headline and inserted introductory text behind that headline. Therefore my code there is:

    					<h4-a><?php _e( 'Profile Details - Teil II: Kontaktendaten', 'buddypress' ); ?></h4-a>
    
    				<p><small><em>Beachte bitte, dass Du in zu den Profilfeldern in diesem Abschnitt selbst entscheiden kannst, wem Deine Angaben, die machst, angezeigt werden sollen.</small></em></p>
    #202778
    1a-spielwiese
    Participant

    I decided to test theses instructions – and in general they work.

    My registration page has now a new design:

    http://1a-spielwiese.de/registrieren/

    This result I got using two means:

    1st:

    I tested with ‘Simple Custom CSS’-Plugin that code:

    #buddypress .standard-form #basic-details-section, #buddypress .standard-form #blog-details-section, #buddypress .standard-form #profile-details-section {
        border: 2px solid #8b008b;
    	float: none;
      	clear: left;
      	width: 100%;
      	padding: 10px;
      	margin-bottom: 1em;
    }
    
    #user-role-section {
      	border: 2px solid #8b008b;
        float: none;
        width: 100%;
      	padding: 10px;
    }
    
    #wp_rar_user_role {
          width: 100%;
        }
    
    h4-a {
    	color: #8b008b;
    	font-size: 11px;
    	font-size: 1.1rem;
      	font-weight: bold;
    	letter-spacing: 0.05em;
    	line-height: 1.9091;
    	text-transform: uppercase;
    }
    
    .wp-editor-container {
        border: 1px solid #DCDCDC;
    }

    Finally I will insert it into my child-theme.

    2nd:

    The relecant section of the register.php with in my reddle-child/buddypress/members-folder is now:

    		<?php if ( 'request-details' == bp_get_current_signup_step() ) : ?>
    
    			<?php do_action( 'template_notices' ); ?>
    
    			<p><?php _e( 'Mitglied bei 1a-Spielwiese zu werden, ist sehr einfach - und kostenlos. F&uuml;lle einfach die Felder unten aus und wir erstellen f&uuml;r Dich umgehend ein Benutzer/in/konto und in K&uuml;rze auch einen eigenen Blog (Webseite).', 'buddypress' ); ?></p>
    
    			<?php do_action( 'bp_before_account_details_fields' ); ?>
    
    			<div class="register-section" id="basic-details-section">
    
    				<?php /***** Basic Account Details ******/ ?>
    
    				<h4-a><?php _e( 'Account Details', 'buddypress' ); ?></h4-a>
    
    				<p><small><em>Diese Daten werden f&uuml;r Deine Registrierung als neues Mitglied und die Einrichtung Deines eigenen Blogs (Webseite) ben&ouml;tigt.</em></small></p>
    
    				<label for="signup_username"><?php _e( 'Username', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
    				<?php do_action( 'bp_signup_username_errors' ); ?>
    				<input type="text" name="signup_username" id="signup_username" value="<?php bp_signup_username_value(); ?>" />
    
    				<label for="signup_email"><?php _e( 'Email Address', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
    				<?php do_action( 'bp_signup_email_errors' ); ?>
    				<input type="text" name="signup_email" id="signup_email" value="<?php bp_signup_email_value(); ?>" />
    
    				<label for="signup_password"><?php _e( 'Choose a Password', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
    				<?php do_action( 'bp_signup_password_errors' ); ?>
    				<input type="password" name="signup_password" id="signup_password" value="" class="password-entry" />
    				<div id="pass-strength-result"></div>
    
    				<label for="signup_password_confirm"><?php _e( 'Confirm Password', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
    				<?php do_action( 'bp_signup_password_confirm_errors' ); ?>
    				<input type="password" name="signup_password_confirm" id="signup_password_confirm" value="" class="password-entry-confirm" />
    
    				<?php do_action( 'bp_account_details_fields' ); ?>
    
    			</div><!-- #basic-details-section -->
    
    			<?php do_action( 'bp_after_account_details_fields' ); ?>
    
    			<?php /***** Extra Profile Details ******/ ?>
    
    			<?php if ( bp_is_active( 'xprofile' ) ) : ?>
    
    				<?php do_action( 'bp_before_signup_profile_fields' ); ?>
    
    				<div class="register-section" id="profile-details-section">
    
    					<h4-a><?php _e( 'Profile Details', 'buddypress' ); ?></h4-a>
    
    				<p><small><em>Diese Daten werden k&uuml;nftig in Deinem Profil angezeigt. Einige Angaben sind verpflichtend, um aussagekr&auml;ftige Profile zu erhalten; bei anderen Formularfeldern ist es Dir selbst &uuml;berlassen, ob Du Angaben machst oder nicht.</small></em></p>
    
    					<?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?>
    
    					<?php if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( array( 'profile_group_id' => 1, 'fetch_field_data' => false ) ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
    
    					<?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
    
    						<div<?php bp_field_css_class( 'editfield' ); ?>>
    
    							<?php
    							$field_type = bp_xprofile_create_field_type( bp_get_the_profile_field_type() );
    							$field_type->edit_field_html();
    
    							do_action( 'bp_custom_profile_edit_fields_pre_visibility' );
    
    							if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?>
    								<p class="field-visibility-settings-toggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>">
    									<?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?> <a href="#" class="visibility-toggle-link"><?php _ex( 'Change', 'Change profile field visibility level', 'buddypress' ); ?></a>
    								</p>
    
    								<div class="field-visibility-settings" id="field-visibility-settings-<?php bp_the_profile_field_id() ?>">
    									<fieldset>
    										<legend><?php _e( 'Who can see this field?', 'buddypress' ) ?></legend>
    
    										<?php bp_profile_visibility_radio_buttons() ?>
    
    									</fieldset>
    									<a class="field-visibility-settings-close" href="#"><?php _e( 'Close', 'buddypress' ) ?></a>
    
    								</div>
    							<?php else : ?>
    								<p class="field-visibility-settings-notoggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>">
    									<?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?>
    								</p>
    							<?php endif ?>
    
    							<?php do_action( 'bp_custom_profile_edit_fields' ); ?>
    
    							<p class="description"><?php bp_the_profile_field_description(); ?></p>
    
    						</div>
    
    					<?php endwhile; ?>
    
    					<input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_field_ids(); ?>" />
    
    					<?php endwhile; endif; endif; ?>
    
    					<?php do_action( 'bp_signup_profile_fields' ); ?>
    
    				</div><!-- #profile-details-section -->
    
    				<?php do_action( 'bp_after_signup_profile_fields' ); ?>
    
    			<?php endif; ?>
    
    			<?php if ( bp_get_blog_signup_allowed() ) : ?>
    
    				<?php do_action( 'bp_before_blog_details_fields' ); ?>
    
    				<?php /***** Blog Creation Details ******/ ?>

    3nd:

    Nevertheless I have two questions regarding the design:

    a) Why the 100%-width for #wp_rar_user_role is ignored?

    b) How can I place the third section (‘Mitglieder-Kategorie’) above the other two sections (or between the other two sections)?

    4th:

    I recognised as well: Deleting there:

    <?php if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( array( 'profile_group_id' => 1, 'fetch_field_data' => false ) ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>

    'profile_group_id' => 1, results in getting not only displaying the ‘base group’ of the xProfile fields, rather all fields of all field groups. 🙂

    Questions:

    a) How can I get the names (titels) of the different xProfile field groups displayed as well?

    b) How can I ensure, that only new members, which choose the user role ‘team’, get displayed the profile fields for teams and new members, which choose the user role ‘fan’, get displayed the profile fields for fans?

    #201151
    1a-spielwiese
    Participant

    Follow-up:

    7th:

    Capability Manager Enhanced to define custom user roles, if you’re not satisfied with the default wordpress roles (subscriber, contributor,…).
    The first step is to create your user roles

    https://buddypress.org/support/topic/resolved-different-profile-types-and-different-user-roles/

    As ready implied there: I did this – and it works so far.

    8th:

    Create a xprofile field (selectbox) with the title “User Role” and name the options “Band Role” and “Fan Role” – in my case. You can call them whatever you want. Place this field in the “base” profile group, otherwise it won’t be shown during registration. Also make the field “required”. In my case the user can’t decide, if the visibility of the field can be changed.

    I did it already, when I installed and activated ‘BP Profile Search’-plugin – and it works.

    However, to choosed a dropdown menu and the categories ‘team’ and ‘fan’.

    9th:

    I modified:

    ?php
    function custom_bp_core_signup_user($user_id) {
        $user_role = strtolower(xprofile_get_field_data('User Role', $user_id));
        switch($user_role) {
            case "Band Role":
                $new_role = 'band';
                break;
            case "Fan Role":
                $new_role = 'fan';
                break;
        }
        wp_update_user(array(
            'ID' => $user_id,
            'role' => $new_role
        ));
    }
    add_action( 'bp_core_signup_user', 'custom_bp_core_signup_user', 10, 1);

    into:

    function custom_bp_core_signup_user($user_id) {
        $user_role = strtolower(xprofile_get_field_data('Mitglieder-Kategorie (Team oder Fan?)', $user_id));
        switch($user_role) {
            case "Team":
                $new_role = team';
                break;
            case "Fan":
                $new_role = 'fan';
                break;
        }
        wp_update_user(array(
            'ID' => $user_id,
            'role' => $new_role
        ));
    }
    add_action( 'bp_core_signup_user', 'custom_bp_core_signup_user', 10, 1);

    (I omitted <?php, because I created not a new bp-costum.php, rather inserted the code into my yet existing bp-costum.php. I inserted the modified code above the line ?>.)

    I did not understand, which effect this insertion should have – but, however, – as far as I see – it causes no harm.

    Did anyone understood, for which purpose the above mentioned code is?

    10th:

    I inserted as well:

    //hide the user role select field in edit-screen to prevent changes after registration
    add_filter("xprofile_group_fields","bpdev_filter_profile_fields_by_usertype",10,2);
    function bpdev_filter_profile_fields_by_usertype($fields,$group_id){
    
    //only disable these fields on edit page
    if(!bp_is_profile_edit())
    return $fields;
    //please change it with the name of fields you don't want to allow editing
    $field_to_remove=array("User Role");
    $count=count($fields);
    $flds=array();
    for($i=0;$i<$count;$i++){
    if(in_array($fields[$i]->name,$field_to_remove))
    unset($fields[$i]);
    else
    $flds[]=$fields[$i];//doh, I did not remember a way to reset the index, so creating a new array
    }
    return $flds;
    }

    into my bp-costum.php – again above the line ?>.

    It does not work:

    — threre the user role is still changeable:

    http://kampfsportlerinnenneuwied.1a-spielwiese.de/wp-content/uploads/sites/2/2014/09/user_role_still_changeble.jpg

    http://1a-spielwiese.de/members/kampfsportlerinnenneuwied/profile/edit/group/1 causes an redirection error. – The redirection error disappears, when I’m not logged in as kampfsportlerinnenneuwied, rather as superadmin.

    #200989
    shanebp
    Moderator

    You’ll probably have to write a custom mysql query.
    Take at look at functions like get_group_ids() in bp-groups -> bp-groups-classes.php to get hints on writing your query.

    Since you have ‘Suggested Groups’, take at look at that code too.

    #198654
    daveodea
    Participant

    Hi,

    Yes creation is enabled for all users.

    > Same problem for when logged in as subscriber role.

    > i don’t see a plugins/bp-custom.php ?

    > i viewed the source and can see the form:

     [edited for length]
        <div class=”entry-content”>
        <div id=”buddypress”>
        <form action=”http://csuni.org/home/groups/create/step/group-settings/” method=”post” id=”create-group-form” class=”standard-form” enctype=”multipart/form-data”>
        <div class=”item-list-tabs no-ajax” id=”group-create-tabs” role=”navigation”>
    
            1. Details
    
            <li class=”current”><span>2. Settings</span>
            <span>3. Forum</span>
            <span>4. Avatar</span>
            <span>5. Invites</span>
    
        </div>
        <div class=”item-body” id=”group-create-body”>
        <div class=”submit” id=”previous-next”>
        <input type=”button” value=”Back to Previous Step” id=”group-creation-previous” name=”previous” onclick=”location.href=’http://csuni.org/home/groups/create/step/group-details'”/>
        <input type=”submit” value=”Next Step” id=”group-creation-next” name=”save”/>
        </div>
        <input type=”hidden” name=”group_id” id=”group_id” value=”0″/>
        </div>
        </form>
    #194701
    richtelford
    Participant

    I’ve managed to achieve what I wanted – fetching activities for the user, the user’s friends, groups that the user is a member of and groups which are tagged with the sports the user is interested in. I’ve added some custom filtering within BuddyPress core functions – I prefer to use filters and hooks but modifying core was my only option in this case.

    My bp_has_activities() request now looks like this:

    
    $args = array(
    	bp_ajax_querystring( 'activity' ),
    	'custom_filter' => array(
    		'relation' => 'OR',
    		array(
    			'user_id' => $user_ids,
    		),
    		array(
    			'group_id' => $group_ids
    		)
    	)
    );
    ?>
    
    <?php if ( bp_has_activities( $args ) ) : ?>
    

    I can share code with anyone interested in this.

    Also fixed a bug in the BP_Groups_Group::get() meta_query code which I’ve detailed above and is now on BP Trac here:

    https://buddypress.trac.wordpress.org/ticket/5874

    #192186
    richtelford
    Participant

    After researching a bit further I think I could easily achieve what I’d like if only this function (in bp-activity-classes.php line 1186):

    
    /**
    	 * Create filter SQL clauses.
    	 *
    	 * @since BuddyPress (1.5.0)
    	 *
    	 * @param array $filter_array {
    	 *     Fields and values to filter by.
    	 *     @type array|string|id $user_id User ID(s).
    	 *     @type array|string $object Corresponds to the 'component'
    	 *           column in the database.
    	 *     @type array|string $action Corresponds to the 'type' column
    	 *           in the database.
    	 *     @type array|string|int $primary_id Corresponds to the 'item_id'
    	 *           column in the database.
    	 *     @type array|string|int $secondary_id Corresponds to the
    	 *           'secondary_item_id' column in the database.
    	 *     @type int $offset Return only those items with an ID greater
    	 *           than the offset value.
    	 *     @type string $since Return only those items that have a
    	 *           date_recorded value greater than a given MySQL-formatted
    	 *           date.
    	 * }
    	 * @return string The filter clause, for use in a SQL query.
    	 */
    	public static function get_filter_sql( $filter_array ) {
    
    		$filter_sql = array();
    
    		if ( !empty( $filter_array['user_id'] ) ) {
    			$user_sql = BP_Activity_Activity::get_in_operator_sql( 'a.user_id', $filter_array['user_id'] );
    			if ( !empty( $user_sql ) )
    				$filter_sql[] = $user_sql;
    		}
    
    		if ( !empty( $filter_array['object'] ) ) {
    			$object_sql = BP_Activity_Activity::get_in_operator_sql( 'a.component', $filter_array['object'] );
    			if ( !empty( $object_sql ) )
    				$filter_sql[] = $object_sql;
    		}
    
    		if ( !empty( $filter_array['action'] ) ) {
    			$action_sql = BP_Activity_Activity::get_in_operator_sql( 'a.type', $filter_array['action'] );
    			if ( ! empty( $action_sql ) )
    				$filter_sql[] = $action_sql;
    		}
    
    		if ( !empty( $filter_array['primary_id'] ) ) {
    			$pid_sql = BP_Activity_Activity::get_in_operator_sql( 'a.item_id', $filter_array['primary_id'] );
    			if ( !empty( $pid_sql ) )
    				$filter_sql[] = $pid_sql;
    		}
    
    		if ( !empty( $filter_array['secondary_id'] ) ) {
    			$sid_sql = BP_Activity_Activity::get_in_operator_sql( 'a.secondary_item_id', $filter_array['secondary_id'] );
    			if ( !empty( $sid_sql ) )
    				$filter_sql[] = $sid_sql;
    		}
    
    		if ( ! empty( $filter_array['offset'] ) ) {
    			$sid_sql = absint( $filter_array['offset'] );
    			$filter_sql[] = "a.id >= {$sid_sql}";
    		}
    
    		if ( ! empty( $filter_array['since'] ) ) {
    			// Validate that this is a proper Y-m-d H:i:s date
    			// Trick: parse to UNIX date then translate back
    			$translated_date = date( 'Y-m-d H:i:s', strtotime( $filter_array['since'] ) );
    			if ( $translated_date === $filter_array['since'] ) {
    				$filter_sql[] = "a.date_recorded > '{$translated_date}'";
    			}
    		}
    
    		if ( empty( $filter_sql ) )
    			return false;
    
    		return join( ' AND ', $filter_sql );
    	}

    would allow filters to be combined with OR rather than AND. That way I could easily filter on a bunch of user_ids and group_ids which would get me the results I’m after. I might try extending the class and overriding that function. Watch this space!

Viewing 25 results - 226 through 250 (of 567 total)
Skip to toolbar