Replies
Yes im using Ray’s plugin from github
Thanks sir
- Tosin on February 8, 2023 at 9:15 am in reply to: Dynamic change of Name Profile field label based on member type selection #48321
This plugin https://wordpress.org/plugins/bp-profile-field-duplicator/ can be used to duplicate the (Name) field but the newly duplicated fields cannot be made to be the (PRIMARY) name field
- Tosin on February 8, 2023 at 9:11 am in reply to: Dynamic change of Name Profile field label based on member type selection #48320
Hello Brajesh
I would also prefer to use different fields but the issue is the (Name) field is the default primary buddypress registration field which handles names across the entire buddypress pages. This field cannot be duplicated and member types pro cannot apply conditional visibility to the field.
Where this is an issue is I don’t want the field label name to be the generic (Name) but I want it to be more contextual like (First & Last Name), (Business Name) according to the selected member type.
For Example
When users register they only input only their first name instead of both first and last name because the label is just (Name) but If I use the label (First & Last Name) this will add more context for the type of data needed. Now the other problem is if I use the label (First & Last Name) and a user selects the member type BUSINESS then I feel the appropriate label now needs to change to (Business Name).
Thanks
- Tosin on January 30, 2023 at 11:18 am in reply to: [Resolved] Turn activity excerpt into clickable link #48185
thanks Brajesh,
This helped
/* turn activity excerpt into a clickable link */ add_filter( 'bp_activity_create_summary', function ( $summary, $content, $activity, $extracted_media ) { if ( 'new_blog_post' !== $activity['type'] ) { return $summary; } // Get post title. $post_title = get_the_title( $activity['secondary_item_id'] ); // Get featured image. $featured_image = get_the_post_thumbnail( $activity['secondary_item_id'], 'thumbnail' ); // Recreate summary. $summary = bp_create_excerpt( html_entity_decode( $content ), 225, array( 'html' => false, 'filter_shortcodes' => true, 'strip_tags' => true, 'remove_links' => true, ) ); $permalink = get_permalink( $activity['secondary_item_id'] ); return "<a href='" . esc_url( $permalink ) . "'>" . $post_title . "</a>" . "<a href='" . esc_url( $permalink ) . "'>" . $featured_image . "</a>" . "<a href='" . esc_url( $permalink ) . "'>" . $summary . "</a>"; }, 10, 4 );
- Tosin on January 28, 2023 at 10:20 am in reply to: [Resolved] Buddypress register redirect url #48171
Hi Brajesh
Using the code you provided at https://buddydev.com/redirect-users-to-welcome-page-after-successful-registration-on-your-buddypress-based-social-network/
How can I make the (welcome) page only accessible if the user is being redirected from the buddypress registration page, while any other direct access to (welcome) page will be redirected to home page
- Tosin on January 28, 2023 at 10:14 am in reply to: [Resolved] Turn activity excerpt into clickable link #48170
Gentle reminder sir, thanks
- Tosin on January 13, 2023 at 10:15 am in reply to: [Resolved] Turn activity excerpt into clickable link #47997
Thanks Brajesh
I will still like to proceed with this, I will really appreciate your assistance with the best solution.
- This reply has been marked as private.
Hi Brajesh
This is the improved code, there are no more issues
<?php /* * Plugin Name: BuddyPress Registration Control * Description: Allows administrators to enable or disable user registration and select a URL to redirect to when registration is disabled. * Version: 1.0 */ // Register the new setting in the BuddyPress options group function custom_bp_register_settings() { if ( ! function_exists( 'bp_is_active' ) ) { return; } register_setting( 'buddypress', 'bp-disable-site-registration', 'custom_bp_sanitize_registration_status' ); register_setting( 'buddypress', 'bp-disable-site-registration-redirection-url', 'custom_bp_sanitize_redirection_url' ); register_setting( 'buddypress', 'bp-close-registration-at-users', 'custom_bp_sanitize_user_registration_count' ); } add_action( 'admin_init', 'custom_bp_register_settings' ); // add sanitization function function custom_bp_sanitize_registration_status( $status ) { $allowed_values = array( 'open', 'closed' ); if ( ! in_array( $status, $allowed_values ) ) { $status = 'open'; } return $status; } function custom_bp_sanitize_redirection_url( $url ) { return wp_kses_post( $url ); } function custom_bp_sanitize_user_registration_count( $count ) { return absint( $count ); } // Add the new setting to the BuddyPress options page function custom_bp_add_settings_field() { if ( ! function_exists( 'bp_is_active' ) ) { return; } add_settings_field( 'bp-disable-site-registration', __( 'Registration', 'buddypress' ), 'custom_bp_settings_field_html', 'buddypress', 'bp_main', array( 'label_for' => 'bp-disable-site-registration', ) ); add_settings_field( 'bp-disable-site-registration-redirection-url', __( 'Redirection URL', 'buddypress' ), 'custom_bp_settings_redirection_url_html', 'buddypress', 'bp_main', array( 'label_for' => 'bp-disable-site-registration-redirection-url', ) ); add_settings_field( 'bp-close-registration-at-users', __( 'Limit User Registration Count', 'buddypress' ), 'custom_bp_close_registration_at_users_html', 'buddypress', 'bp_main', array( 'label_for' => 'bp-close-registration-at-users', ) ); } add_action( 'bp_register_admin_settings', 'custom_bp_add_settings_field', 10, 1 ); // Output the HTML for the setting field function custom_bp_settings_field_html() { $value = get_option( 'bp-disable-site-registration', 'open' ); ?> <select name="bp-disable-site-registration" id="bp-disable-site-registration"> <option value="open" <?php selected( $value, 'open' ); ?>><?php _e( 'Open', 'buddypress' ); ?></option> <option value="closed" <?php selected( $value, 'closed' ); ?>><?php _e( 'Closed', 'buddypress' ); ?></option> </select> <?php } // Output the HTML for the redirection URL field function custom_bp_settings_redirection_url_html() { $value = get_option( 'bp-disable-site-registration-redirection-url', home_url() ); ?> <input type="text" name="bp-disable-site-registration-redirection-url" id="bp-disable-site-registration-redirection-url" value="<?php echo esc_attr( $value ); ?>" required/> <?php } // Output the HTML for the close registration at users field function custom_bp_close_registration_at_users_html() { $value = get_option( 'bp-close-registration-at-users' ); ?> <input type="number" name="bp-close-registration-at-users" id="bp-close-registration-at-users" value="<?php echo esc_attr( $value ); ?>" required/> <p class="description"><?php _e( 'Enter the maximum number of users allowed to register on the site. Leave it empty or set to 0 for no limit.', 'buddypress' ); ?></p> <?php } // Check if registration is open or closed function custom_bp_redirect_registration() { $total_users = count_users(); $total_users = $total_users['total_users']; $registration_status = get_option( 'bp-disable-site-registration', 'open' ); $limit_user_registration_count = get_option( 'bp-close-registration-at-users' ); if ( bp_is_register_page() && $registration_status === 'closed' && ( (empty($limit_user_registration_count) || $limit_user_registration_count == 0) || $total_users >= $limit_user_registration_count ) ) { wp_redirect( get_option( 'bp-disable-site-registration-redirection-url' ) ); exit; } } add_action( 'bp_screens', 'custom_bp_redirect_registration' );
I still faced some issues when the plugin is activated and setting option set to (open) the sign-up page is not loading