Replies
Hi Christopher,
Thank you for asking and posting the code.
Here is the code that I had posted on our old forum for one of our members and it still works. It does not need you to change cssfunction buddydev_disable_firstname() { ?> <script type="text/javascript"> jQuery(document).ready(function(){ var jq=jQuery; jq("#signup_username").on("blur",function(){ jq("#field_1").val(jq("#signup_username").val()); }); }); </script> <?php } add_action( 'bp_after_register_page', 'buddydev_disable_firstname');
It is almost same as yours, just does not need any css modification.
Hope that helps.
Hi Markus,
My apologies for the delayed reply.The plugin does not contain login window. It is easy to implement login but I haven’t done that due to design issues.
What do you think will be the best way to have it? How do you imagine for your community(I need design ideas here). please do let me know and I will do it.
- Brajesh Singh on January 14, 2016 at 2:38 pm in reply to: [Resolved] Bug with featured image – BuddyBlog / Simple Front End Post. #2317
Hi Rodolfo,
Which version of BuddyPress & WordPress are you using? Is it a multisite install? Also, the user posting was a normal user or admin? - Brajesh Singh on January 14, 2016 at 2:37 pm in reply to: [Resolved] How to modify wp-admin-bar-my-account? #2316
Just did it
https://buddypress.trac.wordpress.org/ticket/6824 🙂 - Brajesh Singh on January 13, 2016 at 5:58 pm in reply to: [Resolved] BBpress – restrict topic creation #2311
You are most welcome. Glad, I was able to help 🙂
- Brajesh Singh on January 13, 2016 at 5:58 pm in reply to: [Resolved] BBpress Thread Prefix Plugin Idea #2310
Thank you Joshua.
I looked at it. Looks perfect to me 🙂 - Brajesh Singh on January 13, 2016 at 12:46 pm in reply to: [Resolved] How to modify wp-admin-bar-my-account? #2307
Thank Christopher for taking time to reply. Appreciate it 🙂
PS: I wrote a blog post yesterday to make t available for everyone. Thank you Hans for bringing it 🙂
https://buddydev.com/buddypress/enhancing-my-account-menu-with-buddypress-in-the-adminbar/ - Brajesh Singh on January 13, 2016 at 10:25 am in reply to: [Resolved] BBpress – restrict topic creation #2306
Hi Joshua,
I have updated the code.
There was a logical issue where I used bpp_is_forum() that does not check for current forum just the post type. Have updated the code now. - Brajesh Singh on January 12, 2016 at 9:11 pm in reply to: [Resolved] BBpress – restrict topic creation #2300
Hi Joshua,
Thank you.
You can put the following code in your theme’s functions.php and it will workfunction buddydev_bbp_restrict_topic_creation( $can ) { $forum_id = 222;//change your forum id if ( ! bbp_is_user_keymaster() && bbp_is_single_forum() && $forum_id == bbp_get_forum_id() ) { $can = false; } return $can; } add_filter( 'bbp_current_user_can_publish_topics', 'buddydev_bbp_restrict_topic_creation' ); function buddydev_restrict_from_posting_topic( $forum_id ) { $restricted_forum_id = 222; if ( ! bbp_is_user_keymaster() && $forum_id == $restricted_forum_id ) { //set error on bbpress and it will not allow creating topic //not the best idea but I personaly don't like the way bbpress does not provide any forum info at other places to hook bbp_add_error( 403, __( 'Not allowed' ) ); } } add_action( 'bbp_new_topic_pre_extras', 'buddydev_restrict_from_posting_topic' );//
The first filter prevents showing the topic creation form on single forum screen. The second action hook checks at the time of publish and restricts. Most of the time, the first one will suffice but that just hides the form, so I used the other hook to make sure the user is never able to post new topic.
Please let me know how it goes.
- This reply was modified 9 years, 9 months ago by
Brajesh Singh. Reason: Fixing the bug in code
- This reply was modified 9 years, 9 months ago by
Hi Peter,
After looking at our admin panel, It does not seem a good idea to allow checking the terms and there can be multiple taxonomies allowed and that can lead to a lot of confusion.So, I am posting code snippet to make it work like you want here. You can put these snippets in your bp-custom.php or your theme’s functions.php
Step 1: decide the taxonomy and terms you want to limit users
function buddyblog_custom_get_allowed_taxonomy() { return 'category';//your taxonomy } function buddyblog_custom_get_allowed_term_ids() { return array( 1,2,23 );//your own set of ids for category }
Change the values in these two functions as appropriate. We will use it in our next step.
Step 2: Limiting Users to post to certain terms only
/** * Limit User posts to selected category only * * @param int $settings * @return int */ function buddyblog_selected_cats_only( $settings ) { $taxonomy = buddyblog_custom_get_allowed_taxonomy();//which tax we are limiting too , you must have selected it in the admin settings if ( $settings['tax'][ $taxonomy ] ) { $settings['tax'][ $taxonomy ]['include'] = buddyblog_custom_get_allowed_term_ids() ;//array of term ids in that taxonomy } return $settings; } add_filter( 'buddyblog_post_form_settings', 'buddyblog_selected_cats_only' );
That’s all, you don’t need to make any change in the second block as it uses the values from first block.
Step 3: Do it only if you want to limit certain posts to be linked on profile and not others
function buddyblog_filter_posts_permalink_preference( $pref, $post ) { $terms = get_the_terms( $post, buddyblog_custom_get_allowed_taxonomy() ); if ( empty( $terms ) ) { //what to do when there are no cats attached //you decide return $pref; } $selected_term_ids = buddyblog_custom_get_allowed_term_ids(); $term_ids = wp_list_pluck( $terms, 'term_id' ); $has_selected_terms = array_diff( $term_ids, $selected_term_ids ); //all or atleast one term found if ( empty( $has_selected_terms ) || count( $has_selected_terms ) != count( $term_ids ) ) { $pref = true; //yes show it on profile } else { $pref = false; //dont show it on profile } return $pref; //return false if you don't want post to be linked to profile } add_filter( 'buddyblog_show_posts_on_profile', 'buddyblog_filter_posts_permalink_preference', 10, 2 );
In the above example, we are doing it based on the selected category. I don’t think it is a good strategy as we we are looking for the post terms before deciding permalink. There is a better solution using custom meta. We store a meta field( “_is_buddyblog_post”) whenever a post is posted/edited from front end(It was added in 1.1 and due to back compatibility I can not use in the plugin itself).
The simple way to filter permalink should to be to check if this meta exists and if yes, link to profile else link to normal like below
function buddyblog_filter_posts_permalink_preference2( $pref, $post ) { if( get_post_meta( $post->ID, '_is_buddyblog_post', true ) ) { //this was posted via buddyblog $pref = true; } else { $pref = false; } return $pref; //return false if you don't want post to be linked to profile } add_filter( 'buddyblog_show_posts_on_profile', 'buddyblog_filter_posts_permalink_preference2', 10, 2 );
You can play with the filter ‘buddyblog_show_posts_on_profile’ and decide which posts should be linked on the profile and which should not be.
Hope that helps.
- This reply was modified 9 years, 9 months ago by
Brajesh Singh.
- This reply was modified 9 years, 9 months ago by