Is it possible to add a field (like a checkbox for example) to a custom form in BuddyBlog Pro that is only available to people in a certain role?
Hi Chris,
Thank you for the question.I am sorry, we don’t have conditional fields yet.
If you want to have two forms with different fields(for same post type) with different roles, that is still doable.
Please create 2 forms with different fields and let me know their ids as well as the role they should be used for.
I can provide you couple of lines of code to achieve that.
Regards
BrajeshThank you!
27931 – Subscriber
27932 – Staff, Administrator
Hi Chris,
Thank you.Which post type are you using? Is it the default Post post type?
Regards
BrajeshHi Chris,
hope you are doing well.Please upgrade to BuddyBlog Pro 1.2.9 and put this code in wp-content/plugins/bp-custom.php or in your themes functions.php (Or if you are using a code snippet manager, you can put it using that)
/** * Filters BuddyBlog Pro form for roles. */ add_filter( 'bblpro_post_type_associated_form_id', function ( $form_id, $post_type ) { if ( ! is_user_logged_in() || 'ccwky_announcements' !== $post_type ) { return $form_id; } $roles = wp_get_current_user()->roles; if ( in_array( 'subscriber', $roles ) ) { $form_id = 27931; } else if ( array_intersect( array( 'staff', 'administrator' ), $roles ) ) { $form_id = 27932; } return $form_id; }, 10, 2 );
It will show the specific forms for the roles.
Regards
BrajeshI just wanted to follow up and say thank you.
This is working great!
Thank you Chris.
I am glad it worked.Regards
Brajesh
The topic ‘ [Resolved] Custom Fields Per Role in BuddyBlog Pro’ is closed to new replies.