Skip to:
Content
Pages
Categories
Search
Top
Bottom

Can no longer manually edit register.php


  • GreyWyvern
    Participant

    @greywyvern

    I am using WP 4.3.1 installed as a directory in root. In order to combat spam registrations, I have been manually editing the register.php files and bp-members-screens.php files each time I update Buddypress to add a challenge field with a simple question. These were the files I was editing:

    To add the challenge field:
    \wp-content\plugins\buddypress\bp-templates\bp-legacy\buddypress\members\register.php
    \wp-content\plugins\buddypress\bp-themes\bp-default\registration\register.php

    To accept the incoming form data:
    \wp-content\plugins\buddypress\bp-members\bp-members-screens.php

    Each Buddypress upgrade would revert these files to the default, and I would manually add the challenge question again. This worked for almost two years, and throughout several Buddypress upgrades, up to and including Buddypress 2.3.x.

    Recently I upgraded from 2.3.x to Buddypress 2.4.3. This was the ONLY change I made. I did not upgrade any themes or other plugins. I went to edit the files above, only to find that editing them no longer affects the registration page. I cleared caches, then disabled all of my caching plugins and even deleted the two register.php files above from the server, and the registration form was not affected. With my manual code addition to bp-members-screens.php that REQUIRES the challenge field text to be present, forms with no challenge field submitted were succeeding. So then I deleted bp-members-screens.php from the server entirely, and registrations were STILL succeeding.

    This leads me to believe that in Buddypress 2.4.x the registration page is generated and processed in a different way, and the files above are no longer used. If so, where can I go to edit them now?

    Thanks in advance for your help.

Viewing 6 replies - 1 through 6 (of 6 total)

  • shanebp
    Moderator

    @shanebp

    Unless you are explicitly using the bp-default theme, you should only be using a template overload of this file:
    \wp-content\plugins\buddypress\bp-templates\bp-legacy\buddypress\members\register.php

    There is no need to touch this file:
    \wp-content\plugins\buddypress\bp-members\bp-members-screens.php

    You can add your challenge to the overload template and then check it using the bp_signup_validate hook.
    Example: https://code.hyperspatial.com/all-code/buddypress-code/buddypress-signup-form-hook/


    GreyWyvern
    Participant

    @greywyvern

    Thank you for the reply. Just so you know, I am an experienced PHP coder, but I’m quite unfamiliar with the WP and Buddypress plugin API, which is why I was adding the challenge question manually right in the PHP files before. So I’m not sure where I would put the bp_signup_validate code you linked. Some specific file?

    I copied my edited register.php (with the challenge question) to the following folder of the theme we’re using:

    /wp-content/themes/blackfyre/buddypress/members/

    There was no file named register.php in this directory previously.

    After clearing any caching plugins, the signup form still only displays the default questions. You can see it here: http://realmsunchained.com/user-registration/

    There should be an additional field under the “Confirm Password” field. Before Buddypress 2.4.x just editing the files I mentioned in the OP caused instant changes to this page. Now the registration form seems to be drawing its code from somewhere completely different.

    Am I going wrong somewhere?


    shanebp
    Moderator

    @shanebp

    Iā€™m not sure where I would put the bp_signup_validate code you linked. Some specific file?

    It can go in your theme/functions.php or in plugins/bp-custom.php

    Re overload register:
    Make sure you start with this file:
    buddypress\bp-templates\bp-legacy\buddypress\members\register.php

    I just did an overload via this path:
    /wp-content/themes/twentythirteen/buddypress/members/register.php
    And the changes appear, so the overloaded template is being loaded.

    You might try switching to a WP theme like 2013 – if the issue disappears, that’s a clue.


    GreyWyvern
    Participant

    @greywyvern

    I activated the twentythirteen theme and uploaded the edited register.php file here:

    /wp-content/themes/twentythirteen/buddypress/members/register.php

    I double checked to make sure that the register.php file I uploaded was from:

    \wp-content\plugins\buddypress\bp-templates\bp-legacy\buddypress\members\register.php

    … and also that my challenge question code was included. It’s inserted at line 51 of the file as follows:

    <!-- Test question -->
    <label for="signup_test">Challenge question? <?php _e( '(required)', 'buddypress' ); ?></label>
    <?php do_action( 'bp_signup_test_errors' ); ?>
    <input type="text" name="signup_test" id="signup_test" value="" />

    After clearing any caching plugins, the challenge question DID NOT appear on the signup form while the twentythirteen theme was active. I have reverted back to the blackfyre template for now.

    Any thoughts?


    shanebp
    Moderator

    @shanebp

    Basic html issue?

    Try putting it right before this:
    </div><!-- #basic-details-section -->


    GreyWyvern
    Participant

    @greywyvern

    That’s where it is. A few lines of context code included:

    ...
    
    				<label for="signup_password_confirm"><?php _e( 'Confirm Password', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
    				<?php do_action( 'bp_signup_password_confirm_errors' ); ?>
    				<input type="password" name="signup_password_confirm" id="signup_password_confirm" value="" class="password-entry-confirm" <?php bp_form_field_attributes( 'password' ); ?>/>
    
    				<?php do_action( 'bp_account_details_fields' ); ?>
    
    <!-- Test question -->
    <label for="signup_test">Challenge question? <?php _e( '(required)', 'buddypress' ); ?></label>
    <?php do_action( 'bp_signup_test_errors' ); ?>
    <input type="text" name="signup_test" id="signup_test" value="" />
    
    			</div><!-- #basic-details-section -->
    
    			<?php do_action( 'bp_after_account_details_fields' ); ?>
    
    ...

    From your responses I’m getting the feeling that what I’m doing should be working, but it isn’t. I’m probably overlooking something simple. šŸ˜

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Can no longer manually edit register.php’ is closed to new replies.
Skip to toolbar