Forum Replies Created
-
In reply to: dynamically create new sets of profile fields
This could be done, but it would take some custom coding. Here’s how I would structure it.
1) Write some JS for the Edit Profile page that inserts a new set of fields based on user input (say, a button that says “Add another employer”). This wouldn’t really require any BP code in and of itself.
2) Hook a function to ‘xprofile_updated_profile’, which is a do_action hook called right after all of the xprofile fields are saved. Grab the $_POST data, and see if there are any items in that array for which no profile fields yet exist. Use xprofile_insert_field() to create the new fields (it might be like employer_2_employer_address – something that iterates nicely).
3) On the front end, you’ll want to make sure that not all of the employer groups are shown to each user on the edit profile screen. By default, each user sees each profile field. That means that if one person on your system listed ten employers, then everyone would see ten employer field groups when they went to edit their profile. You could do this in the profile edit template, by checking bp_get_the_profile_field_name() against a list of permitted field names.
In reply to: is_admin for group admin, can’t find it?When someone gets to the level in question, why not just make them the admin of the group? groups_promote_member( $user_id, $group_id, ‘admin’ ). Then groups_demote_member when they lose their level. Fewer checks to the database that way too – no need to load user level on each group page load.
In reply to: is_admin for group admin, can’t find it?I don’t really get what you’re trying to do with that code. Those admin pages are blocked from regular group members by default. You shouldn’t need any additional code to do that.
I agree it’s generic but I just don’t see a programmatic way to allow easier editing of that information. Languages are too different from each other. Even making it work right for English would be an enormous task.
For what it’s worth, I just happen to be editing a po file right now for a project I’m doing (literally right now – poedit is open on my desktop) and I don’t find it so bad to use. To go through and change all instances of ‘group’ might take ten or fifteen minutes. This is a pretty small investment IMO to essentially change large amounts of text throughout the program.
In reply to: is_admin for group admin, can’t find it?From inside of the group, to check if the logged in user is the group admin,
if ( bp_group_is_admin() )
Elsewhere:
if ( groups_is_user_admin( $user_id, $group_id ) )@modemlooper I’m not sure how .po files are generated. I assume the po-making program just runs through all the files in a directory in alphabetical order and finds strings like that, which would explain why they can be all over the place. Is it true that Poedit doesn’t have a useful search-and-replace? How about just opening the .po file in a plain-text editor, doing a search and replace there, and using Poedit to turn it into a .mo file?
@nit3watch That’s an interesting idea about .po/.mo templates. Maybe in the future, if BP starts shipping with more than one default theme, it could also ship with more than one such default template, just to give people a sense of how you might make BP act differently.
The slug idea might be workable (though awfully messy) for English, but it simply couldn’t work more generally.
It would be impossible to make words like “Group” into an admin-configurable option on a text-heavy software like BuddyPress. In English, we might be able to get away with creating a singular replacement and a plural replacement, but not all languages work this way. In Russian, for example, a word might be in a different form depending on which grammatical part of the sentence it is. For this reason, a simple variable substitution for a widely-used word like ‘group’ can’t work. It has to be on a sentence level, which is essentially what the .pot method provides.
I sympathize with those who have a hard time getting Poedit up and running – I don’t find it that easy to use myself. But I disagree that a language file is the wrong way to solve the problem. To me it seems like exactly the right, and only, way.
Ha ha, glad that replacing .htaccess fixed things!
Shouldn’t matter which version of PHP you run for the sake of WP/BP – WP supports PHP 4.3 and up.
You shouldn’t have to delete the originals. But since the problem happens when you are using bp-default, I would guess that it has nothing to do with your theme.
Sounds like it doesn’t have anything to do with the theme, then. Have you turned on pretty permalinks? Dashboard > Settings > Permalinks, select something other than the default. Also, were you asked at any point during the installation of WP to create an .htaccess fil?
In reply to: New Blogs have weird URL.I know it’s Alex
Better to do this on the forums so that others can benefit from whatever Wisdom We Uncovere.Are you experiencing the same problems when you use the bp-default theme?
In reply to: New Blogs have weird URL.Try deactivating BuddyPress and creating another one through the Dashboard.
In reply to: New Blogs have weird URL.Try creating a new blog from Dashboard > Super Admin > Sites to see if the problem happens there too. At least that way you can narrow down whether it’s a BP issue.
After submitting that patch, I realized that there was a much better way to do it that didn’t involve the hackiness. Check out the second patch on that trac ticket, and add the following line to wp-config.php:
define( 'BP_DISABLE_AUTO_GROUP_JOIN', true );OK, as promised. Here’s how to make it work. Two steps.
1) You’ll have to patch your BuddyPress core files in the following way: https://trac.buddypress.org/attachment/ticket/2540/new_hooks_after_auto_group_join.patch. I’m hoping that the patch will go seamlessly into the core in the next version of BP (it’s less obtrusive than some of the less hackish fixes that Paul was probably thinking of above).
2) Put the following code in your bp-custom.php file: http://pastebin.com/NPSRxG3C.In brief, here’s what happens: when a non-member posts to a group, he still joins the group (necessary in order to be able to post in the group forum). But the user is temporarily flagged as having been auto-joined, and immediately after the post goes through, the user is removed from the group. Also, a little cookie hack makes sure that the user doesn’t get a “You have successfully left the group” message after posting. Let me know if it works.
I can think of an easy way to do this with a plugin (essentially, by removing the poster from the group immediately after having auto-joined and posted, and cleaning up activity items), but it will require an action hook in BP core that isn’t there right now. Tonight or tomorrow I’ll write up a patch and post a message about it in this group.
Bumping this thread because I just wasted half an hour not reading it carefully enough. My loader function was using bp_init, which was too late to catch bp_setup_nav. Beware!!
In reply to: PHPXref being made availableAwesome!!! Thanks @ggholic!
Yeah, it’s not all that easy to populate an xprofile dropdown dynamically. I can think of a few ways to do it, but it might be complex.
Here’s the general direction I’d move: http://pastebin.com/DM8YNzsq Obviously your $_POST array key will be something else, and you may want to do some data checking before saving. But that’s the skeleton of what you need.
It’s going to be more complicated to save items into wp_usermeta (which is I assume what you’re doing, given the link) with update_user_meta() from the BP profile page. You’ll have to hook a function to somewhere in the BP loading process that will catch the value of $_POST and manipulate the data manually.
Can I ask what might be a silly question? Why don’t you just use BP profile fields? Dashboard > BuddyPress > Profile Field Setup. That’ll add new fields to the profile that can be displayed and updated natively through BuddyPress.
Open buddypress/bp-themes/bp-default/members/single. Individual member profiles are created with profile.php and profile/profile-loop.php. There are do_action definitions throughout those templates. Try hooking your function to anyone of them.
In reply to: bp_has_groups() HelpTo the best of my knowledge there is nothing that does that. You could try extending the database class with a new query along those lines, though.
In reply to: bp_has_groups() HelpYikes! bp_has_site_groups() was deprecated a couple versions ago. Use bp_has_groups().
Two ways to pass arguments:
1)bp_has_groups( 'type=random&max=3&user_id=' . $user_id )(just to give you a sense of how you might put a variable in there2)
$args = array(
'type' => 'random',
'max' => 3,
'user_id' => $user_id
);
if ( bp_has_groups ( $args ) ) { ...The second method is a bit easier to handle when you’re passing in a large number of arguments.