This sort of functionality would be great! Is their a way to do this with user roles in wordpress?
Well I thought if I add a custom profile filed. Make it a drop down.
Then all i need to do is check the value of that field on profile/index.php
The profile field is fine. However, how do i then call its value in an if statement?
I think I’ve solved it (but havent built it yet). This is what I’m going to do;
-Write a function in bp-custom.php
– Function takes the current ID and passes that to the db returning the usertype (which is a custom profile field)
– Run the function on profile/index.php
– then do a simple switch statement to show the appropriate template
Ok so I created;
/wp-content/plugins/bp-custom.php with the below in it;
/**
* bp_check_usertype()
* TEMPLATE TAG
*
*/
function bp_check_usertype($userID) {
global $bp, $wpdb;
$qry = $wpdb->get_var("SELECT value FROM wp_bp_xprofile_data WHERE field_id = 5 AND user_id = " . $userID);
/* Sort the nav by key as the array has been put together in different locations */
echo $qry;
}
However when I call it in /bp-themes/mymember/profile/index.php like so;
$bp->bp_check_usertype($bp->displayed_user->id);
I get the following error
Fatal error: Call to undefined function: bp_check_usertype() in /html/wp-content/bp-themes/mymember/profile/index.php on line 31
Am I missing something?
I called the function incorrectly
$bp->bp_check_usertype($bp->displayed_user->id);
should have be
bp_check_usertype($bp->displayed_user->id);
This is a good start. As I’m not too deep into Buddypress yet, I need some more help:
1. which file should I use as a basic user-template?
2. where do i have to put in what (the function)?
I’ve already put a file called bp-custom.php in my wp-content/plugins directory with the above function in it (I’m using wpmu 2.8.5.2 and bp 1.1.2).
Now in which template-file do I have to put the call bp_check_usertype($bp->displayed_user->id); ?
This is one of the last features I would need to put my site online.
Thank you for helping me!
Any way this could be wrapped into a plugin?
No one out there who can help?