Forum Replies Created
-
Have you tried using serialized arrays with the current fields?
I found the issue. It was the plugin autoptimize.
I’m having the same issue.
This is what I changed in functions.php. It was do to with adding subnav items, removing subnav items and renaming some of them:
/* BP Add subnavigation on profile */ add_action('bp_setup_nav', 'bp_profile_submenu_profile' ); function bp_profile_submenu_profile() { global $bp; if(!is_user_logged_in()) return ''; bp_core_new_subnav_item( array( 'name' => 'Seminar Bookings', 'slug' => 'seminar-bookings', 'parent_url' => $bp->loggedin_user->domain . $bp->bp_nav['profile']['slug'] . '/' , 'parent_slug' => $bp->bp_nav['profile']['slug'], 'position' => 20, 'screen_function' => 'seminar_bookings' ) ); } function seminar_bookings() { add_action( 'bp_template_content', 'seminar_bookings_screen' ); bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) ); } function seminar_bookings_screen() { locate_template( array( 'buddypress/members/single/profile/seminar-bookings.php' ), true ); } /* BP Remove unneeded subnav items */ function remove_bp_subnav_items() { global $bp; bp_core_remove_subnav_item('profile','change-avatar'); bp_core_remove_subnav_item('profile','change-cover-image'); } add_action( 'bp_setup_nav', 'remove_bp_subnav_items'); /* BP Rename subnav items */ function rename_bp_subnav_items(){ global $bp; $bp->bp_options_nav['profile']['edit']['name'] = 'Edit Profile'; $bp->bp_options_nav['profile']['public']['name'] = 'View Profile'; } add_action('bp_setup_nav', 'rename_bp_subnav_items', 201);
The only time I had mentioned ‘position’ was when setting up a new subnav item.
Update: Figured it out. This post helped ALOT https://buddypress.org/support/topic/assigning-new-subnav-items/
Update: I’m considering just removing the
bp_get_options_nav();
from profile.php and adding the required links in there. Any downsides to this?Hi
Thanks for the responses. I have just copied and pasted the output. I had done this before and it had worked fine. The reason I was trying to do it more like the way the vanilla BP works is due to TinyMCE not working when I copy and paste it, but I can live with just a normal text area. Thanks for the help 🙂
@klame – Hey. Yep, it goes in bp_custom.php, though I think you could also put it into your functions.php if you wanted (depends if you want the same functionality if you change theme).
Keep _member_role as it is. The ‘yourrole’ and ‘myrole’ are the names of your user roles that you created, e.g. ‘subscriber’, ‘administrator’ etc.
Thanks @danbp. I was actually thinking about this and twitter uses their public usernames for logins, so I guess I’m just being paranoid!
Ok, I figured it. For anyone that has the same issue, I put the following code in my functions.php, though I think it would work fine in a plugin too.
add_action('xprofile_avatar_uploaded','redirectAfterAvatarUpload' ); function redirectAfterAvatarUpload() { $location = '/members/'.bp_core_get_username(bp_loggedin_user_id()).'/profile/edit/group/1/'; bp_core_redirect($location); return; }
@henrywright – You didn’t see my post afterwards. I managed to get it all working 🙂
Ok, I have this working! For anyone else struggling with this, these are the steps I took:
1. I created a custom registration form ( I needed more than one form for my setup) using the tutorial from Brajesh Singh http://buddydev.com/buddypress/show-buddypress-user-registration-form-everywhere-buddypress-site/
2. I added a hidden input field to my form:
<input type="hidden" name="user_type" id="user_type" value="your_role" />
3. I added a user_meta during the registration to store the role for later use during the activation process:
function store_user_role($user_id) { $user_type = $_POST['user_type']; $user_role = $user_type; switch($user_role) { case "your_role": add_user_meta( $user_id, '_member_role', 'yourrole'); break; case "my_role": add_user_meta( $user_id, '_member_role', 'myrole'); break; default: add_user_meta( $user_id, '_member_role', 'defaultrole'); } } add_action( 'bp_core_signup_user', 'store_user_role', 20, 1);
4. Then during the activation process you check to see which user role is stored in the user_meta, and assign that as the actual WP user role:
add_action('bp_core_activated_user', 'bp_custom_registration_role',10 , 3); function bp_custom_registration_role($user_id, $key, $user) { $userdata = array(); $userdata['ID'] = $user_id; $key = '_member_role'; $single = 'true'; $userRole = get_user_meta( $user_id, $key, $single ); if ($userRole == 'yourrole') $userdata['role'] = 'yourrole'; if ($userRole == 'myrole') $userdata['role'] = 'myrole'; if (($userdata['role'] == "yourrole") or ($userdata['role'] == "myrole")) wp_update_user($userdata); }
That’s it. I used a few different examples from these support forums so credit goes out to those who got this stuff working in the first place. Hope this helps someone else.
@henrywright – I wrote
$POST_['user_type']
instead of
$_POST['user_type']
D’oh! It still isn’t working though, kind of. The user is actually having the role set during the registration and is showing up in the admin section in Users as an expert, as well as pending. When I activate the account from admin they then get set as a subscriber (the default set by user roles editor). So it appears there’s another step happening after the activation of the account.
Any ideas what I need to look at?
Hi @mastodontmedia – I am having a similar sort of issue. I have a field ‘price’ that I want to sort by. I have read the article that @danbp kindly provided, but I am having a bit of an issue getting my head around it. I’m trying to create new ‘Order By’ effectively. I can create the option within the dropdown on the members loop and even get it to sort by price, but it then breaks plugins such as BP Profile Search, which works with the ‘out of the box’ Order By options.
Hi @henrywright – I set it up as you said above and also set a default via user profile editor as ‘contributor’. The user was registered as a contributor even though it should have been an expert.
Do you think the POST data isn’t getting to this stage? I don’t know how to test it since I can’t echo what’s happening at this stage.
@danbp – Sorry to have so many questions. The example in the link you provided is for the activity loop, but I am trying to get this working for the members loop. Will it still work the same or do I have to take a completely different approach to this?
@danbp – I’m guessing this is the function I need order_by_most_favorited() to edit to work with XProfile fields?
I’ll try it now and see if it works with XProfile fields.
@danbp – Thanks for this. I think I’d seen that before. I can create the new option for ‘Order By’, my issue is actually making it work properly. In that article, I’m not really understanding how I can create a simple ‘Order By’ for a numerical XProfile field.
I used @shanebp code above and it works with pagination unless there is a URL parameter, after which it breaks when navigating from page 2 to any other page. It doesn’t work with a search query ‘s=’ or with BP Profile Search. I think there is something I’m not getting.
The code on the page you provided seems a lot longer than the code shanebp provided above. I think this is really confusing me!
To be honest, if someone could point out how to create a completely new ‘Order By’ option from scratch how they are in the core files then I’d probably go down that route, but I’m not sure how to do that without actually editing the core files. Is there anyway I can hook into that part of the code?
I could then pretty much just copy one of the ‘Order By’ options that currently exists and then just edit the SQL to order by the XProfile field that I want.
@joshklekamp – Add the code to bp-custom.php; however the code is slightly buggy so you would need to test it. If you can figure out why the pagination doesn’t work if there are URL parameters then please do let me know.
Hi @henrywright
I have a quick question. I have included the code from the buddypress registration.php file into a custom page template in my child theme, however it isn’t working as it does within buddypress. Do I need to do something else within my custom template for the buddypress code to work?
I tried
global $bp
as I thought this would work, but nope.I’m looking for something similar, however I want completely separate forms. I can see how to edit the registration page to only show the fields I need as I customised this to my requirements already. My problem is that I want multiple pages with separate forms on them as this would allow me to code them differently to my needs. When I have put the BP registration form code into a custom wordpress page template, this doesn’t display the form fields as it clearly isn’t recognising the BP specific code within the template.
I’m unsure of where to go with this.
Edit: I can get the form to show up now, but when I submit the form, it just reloads the page without registering the new user.
Hi @shanebp – I was wondering if you knew why the pagination doesn’t work when there is a URL parameter in the URL?
Also, am I missing something obvious why this wouldn’t be working with the XProfile Search plugin?
Is there an easy way to REMOVE ‘Order By’ options?
@hnla – Thanks Hugo. Yeah I’m generally ok with the BuddyPress templates, but I keep forgetting to look in bp-templates instead of bp-themes. Bad habits!
@hnla – I was looking in the bp-themes directory not the bp-templates directory. Facepalm.