• Resolved dreamingbear

    (@dreamingbear)


    This is my penny for it. Patch the plugin version 4.0 with this.
    I will be glad to compare my changes with other’s

    --- includes/core.php Mon Oct 22 22:31:36 2012
    +++ includes/core.php Tue Feb 05 23:19:49 2013
    @@ -15,7 +15,7 @@
     add_action( 'init', 'wds_bp_registration_options_core_init' );
     function wds_bp_registration_options_core_init(){
      global $bp_moderate, $bprwg_privacy_network, $wpdb, $bp, $user_ID, $blog_id;
    - if ( !is_admin() ) {
    + if ( !current_user_can( 'edit_users' ) ) {
        if ( is_multisite() ) {
          $blogid = $blog_id;
          switch_to_blog(1);
    @@ -31,14 +31,16 @@
          if ( $bp->current_component && $user_ID == 0 && $bp->current_component != 'register' && $bp->current_component != 'activate' ) {
            if ( $bp->pages->register->slug ) {
              wp_redirect( site_url().'/'.$bp->pages->register->slug );
    +                    exit;
            } else {
              exit();
            }
          //if logged in and not approved then redirect to their profile page
          } elseif ( $bp->current_component && $user_ID > 0 && ( $bp->displayed_user->userdata == '' || $bp->displayed_user->userdata != '' && $bp->displayed_user->id != $user_ID ) ) {
            $user = get_userdata($user_ID);
    -       if ( $user->user_status == 69 ) {
    +       if ( $user->data->user_status == 69 ) {
              wp_redirect( $bp->loggedin_user->domain );
    +                    exit;
            }
          }
        }
    @@ -197,7 +199,7 @@
      *
      */
     add_filter('bp_after_activate_content', 'wds_bp_registration_options_bp_after_activate_content');
    -add_filter('bp_before_member_header', 'wds_bp_registration_options_bp_before_member_header');
    +add_filter('bp_before_member_header', 'wds_bp_registration_options_bp_after_activate_content');
     function wds_bp_registration_options_bp_after_activate_content(){
      global $bp_moderate, $user_ID, $blog_id;
      if ( is_multisite() ) {
    @@ -205,7 +207,7 @@
        switch_to_blog(1);
      }
      if ( $bp_moderate && isset( $_GET['key'] ) || $bp_moderate && $user_ID > 0 ) {
    -   $activate_message = get_option('bprwg_activate_message');
    +   $activate_message = stripslashes(get_option('bprwg_activate_message'));
        echo '<div id="message" class="error"><p>'.$activate_message.'</p></div>';
      }
      if ( is_multisite() ) {
    @@ -220,7 +222,7 @@
      *
      *
      */
    -add_action( 'bp_core_activate_account', 'wds_bp_registration_options_bp_core_activate_account');
    +
     function wds_bp_registration_options_bp_core_activate_account($user_id){
      global $wpdb, $bp_moderate;
      if ( $bp_moderate ) {
    @@ -243,5 +245,5 @@
        }
      }
     }
    -
    +add_action( 'bp_core_activate_account', 'wds_bp_registration_options_bp_core_activate_account');
     ?>
    \ No newline at end of file

    http://wordpress.org/extend/plugins/bp-registration-options/

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter dreamingbear

    (@dreamingbear)

    Some good pickups, I’ll merge the ones i missed with my version here:
    https://github.com/jibbius/bp-registration-options-wp3.5

    Hi dreamingbear,

    Some of your changes seem good to me… but some seem a little bit odd;

    In this example, the exit() seems a good idea:

    $user = get_userdata($user_ID);
    -				if ( $user->user_status == 69 ) {
    +				if ( $user->data->user_status == 69 ) {
     					wp_redirect( $bp->loggedin_user->domain );
    +                    exit;
     				}

    But you change $user (an instance of WP_User), to $user->data.
    I’m pretty sure that’s a bug?

    Also, no idea why you’ve done this:

    -add_filter('bp_before_member_header', 'wds_bp_registration_options_bp_before_member_header');
    +add_filter('bp_before_member_header', 'wds_bp_registration_options_bp_after_activate_content');

    Not saying it’s bad, but what’s it supposed to fix?
    (Asking cause I’m interested in what you were fixing πŸ™‚ )

    Thread Starter dreamingbear

    (@dreamingbear)

    The function wds_bp_registration_options_bp_before_member_header is non-existent, so no action would be performed by the filter. But the entire idea of the filters is to display a message to the unapproved user that he is, actually, unapproved. So the same message can go both on the activation and the member profile page.

    I am perplexed instead on the change I made on line 18 of core.php. If I remember, without this change the plugin did not work at all, either not blocking registration or not showing the page or something similar. But on second thought the call to is_admin is there just to avoid calling the block while the dashbosrd is active.. I must look into this

    Thread Starter dreamingbear

    (@dreamingbear)

    About user->data->user_status, I stepped the code with a debugger and found there the infamous sixty-nine. user->user_status was nonexixtent.

    la79

    (@laguilar79)

    @dreamingbear your link to the patched plugin is not working. Can you provide a new link so I can check out?

    Thanks.

    jibbius

    (@jibbius)

    Hi @dreamingbear, thanks for clarifying.

    I like your reuse of wds_bp_registration_options_bp_after_activate_content().
    The original line 18 seems to be working for me.

    la79

    (@laguilar79)

    @jibbius, @dreamingbear, so I just tried this version everything works, however users can still access website even before I have approved. Is this doing the same thing for you?

    Thread Starter dreamingbear

    (@dreamingbear)

    Forgive me for waiting so long, but lots of other stuff in the line…

    just reuploaded the plugin to http://test.comunitamagnificat.org/large/bp-registration-options.zip, if someone needs it. This file is the original plugin plus a diff file to apply. I have another folk that’s working on the plugin since I have no time left… will post any progress here.

    la79

    (@laguilar79)

    @dreamingbear still no luck your version also allows users to access even before they are approved.

    In dreamingbear patch , line 63

    if ($ bp-> current_component == ‘messages’) {

    I replaced it with:

    if ($ bp-> current_component! =” && $ bp-> current_component! = ‘activity’ && $ bp-> current_component! = ‘profile’) {

    now seems to work well.

    @markitoz thank you for your help. However I do not know how to implement your changes. Should this change be made in the “fix.diff” file? As I do not see on line 63:

    if ($ bp-> current_component == 'messages') {

    I see on line 63:

    ?>

    Can you walk me through? Specifically on how to apply the “fix.diff” file?

    Thanks for your help.

    This is the new fix.diff to apply to the original version:

    --- includes/core.php	2013-05-12 15:35:38.848067700 +0200
    +++ includes/core.php	2013-05-12 15:51:21.728179400 +0200
    @@ -15,7 +15,7 @@
     add_action( 'init', 'wds_bp_registration_options_core_init' );
     function wds_bp_registration_options_core_init(){
     	global $bp_moderate, $bprwg_privacy_network, $wpdb, $bp, $user_ID, $blog_id;
    -	if ( !is_admin() ) {
    +	if ( !current_user_can( 'edit_users' ) ) {
     		if ( is_multisite() ) {
     			$blogid = $blog_id;
     			switch_to_blog(1);
    @@ -31,14 +31,16 @@
     			if ( $bp->current_component && $user_ID == 0 && $bp->current_component != 'register' && $bp->current_component != 'activate' ) {
     				if ( $bp->pages->register->slug ) {
     					wp_redirect( site_url().'/'.$bp->pages->register->slug );
    +                    exit;
     				} else {
     					exit();
     				}
     			//if logged in and not approved then redirect to their profile page
     			} elseif ( $bp->current_component && $user_ID > 0 && ( $bp->displayed_user->userdata == '' || $bp->displayed_user->userdata != '' && $bp->displayed_user->id != $user_ID ) ) {
     				$user = get_userdata($user_ID);
    -				if ( $user->user_status == 69 ) {
    +				if ( $user->data->user_status == 69 ) {
     					wp_redirect( $bp->loggedin_user->domain );
    +                    exit;
     				}
     			}
     		}
    @@ -60,7 +62,7 @@
     				//redirect messages page back to profile (dont want blocked members contacting other members)
     				add_filter( 'bp_get_options_nav_invite', '__return_false' );
     				add_filter( 'bp_get_options_nav_compose', '__return_false' );
    -				if ( $bp->current_component == 'messages' ) {
    +				if ( $bp->current_component !='' && $bp->current_component != 'activity' && $bp->current_component != 'profile') {
     					wp_redirect( $bp->loggedin_user->domain );
     					exit();
     				}
    @@ -197,7 +199,7 @@
      *
      */
     add_filter('bp_after_activate_content', 'wds_bp_registration_options_bp_after_activate_content');
    -add_filter('bp_before_member_header', 'wds_bp_registration_options_bp_before_member_header');
    +add_filter('bp_before_member_header', 'wds_bp_registration_options_bp_after_activate_content');
     function wds_bp_registration_options_bp_after_activate_content(){
     	global $bp_moderate, $user_ID, $blog_id;
     	if ( is_multisite() ) {
    @@ -205,7 +207,7 @@
     		switch_to_blog(1);
     	}
     	if ( $bp_moderate && isset( $_GET['key'] ) || $bp_moderate && $user_ID > 0 ) {
    -		$activate_message = get_option('bprwg_activate_message');
    +		$activate_message = stripslashes(get_option('bprwg_activate_message'));
     		echo '<div id="message" class="error"><p>'.$activate_message.'</p></div>';
     	}
     	if ( is_multisite() ) {
    @@ -220,7 +222,7 @@
      *
      *
      */
    -add_action( 'bp_core_activate_account', 'wds_bp_registration_options_bp_core_activate_account');
    +
     function wds_bp_registration_options_bp_core_activate_account($user_id){
     	global $wpdb, $bp_moderate;
     	if ( $bp_moderate ) {
    @@ -243,5 +245,5 @@
     		}
     	}
     }
    -
    +add_action( 'bp_core_activate_account', 'wds_bp_registration_options_bp_core_activate_account');
     ?>
    \ Manca newline alla fine del file
    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Marking resolved

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘My patch to fix it with WP3.5’ is closed to new replies.