Support

Home Forums WP User Integration user integration templates, child theme

user integration templates, child theme

Posted: June 2, 2016 at 4:19 am


robbstcs

June 2, 2016 at 4:19 am

Hi,

I’ve placed eea-wp-users-login-form.template.php in my child theme ‘u-desgin-child’ (u-desgin-child>eea-wp-users-login-form.template.php) and under u-desgin-child>eea-wp-user-integration>eea-wp-users-login-form.template.php.

Yet the custom template isn’t working. Where else can I put this template file in my child theme so that it overrides the default template.

Thanks


Tony

  • Support Staff

June 2, 2016 at 4:31 am

Hi there,

Currently the EE4 User Integration add-on does not allow you to override that template.

Can I ask what you are looking to do with the template?


robbstcs

June 2, 2016 at 4:36 am

hi Tony,

I’m trying to remove the register link and replace it with a ‘forgotten password’ link.


robbstcs

June 2, 2016 at 5:55 am

Hi Tony,

the code to put the register button on the form is if ( get_option( 'users_can_register' ) ) but im worried if I disable the ‘users can register’ does this mean that events espresso won’t be able to create new users when they purchase?


robbstcs

June 2, 2016 at 5:56 am

because there is a wordpress setting where you can turn off the ability to register, but will this break the events espresso wp user integration plugin?


robbstcs

June 2, 2016 at 5:57 am

oh, and I guess that still won’t let me put a forgotten password link on there 🙁


Tony

  • Support Staff

June 2, 2016 at 6:15 am

Disabling that option should still allow EE to create users however as you mentioned it will not allow you to add forgotten password link.

The template is loaded using the ‘display_template’ method which does not check for custom versions of the plugin, however there is a filter within that function that will allow you to check the current template and replace it with your own:

apply_filters( 'FHEE__EEH_Template__display_template__template_path', $template_path );

$template_path will be an absolute path to the template file, so you can hook into that, pull the current template file using basename( $template_path ); and if it is ‘eea-wp-users-login-form.template.php’ replace $template_path with your own full template_path there.

I’ll check in with our developers but usually when we use display_template() to output a template it is to prevent changes to the template that could have a knock on effect and cause further problems.


robbstcs

June 2, 2016 at 6:57 am

Hi Tony,

thanks for that, I’ve attempted a function in my functions.php file:

//switch ee-user-integration log in form template out with a new one in the child theme.
if ( ! function_exists( 'custom-ee-login-forgotpassword-template' ) ) :
function custom-ee-login-forgotpassword-template() {
	if (basename( $template_path ) == 'eea-wp-users-login-form.template.php'){
		$template_path = 'wp-content/themes/u-desgin-child/eea-wp-users-login-form.template.php';
		apply_filters( 'FHEE__EEH_Template__display_template__template_path', $template_path );
	}
}
endif;

but must be going wrong somewhere?

Thanks


robbstcs

June 2, 2016 at 8:47 am

Hi Tony,

I have been thinking, it may be easier to just add a forgotten password button next to the login button. I’ve found what seems to be the action/filter that is giving the message when a user tries to checkout with an email that already exists:

EED_WP_Users_SPCO__verify_user_access__perform_email_user_match_check

and this outputs the message `$error_message = ‘<p>’ . __( ‘You have entered an email address that matches an existing user account in our system. If this is your email address, please log in before continuing your registration. Otherwise, register with a different email address.’, ‘event_espresso’ ) . ‘</p>’;

/**
* @todo ideally the redirect url would come
* back to the same page after login. For
* now we’re just utilizing js/ajax for login
* processing so users with js supported
* browsers will just stay on the loaded page.
*/
$error_message .= ‘<a class=”ee-roundish ee-orange ee-button float-right ee-wpuser-login-button” href=”‘ . wp_login_url( $spco->checkout->redirect_url ) . ‘”>’ . __( ‘Login’, ‘event_espresso’ ) . ‘</a>’;`

So therefore I have tried to add more to the $error_message variable in my functions.php with the following code:

 function my_add_forgotten_password_btn() {
	if ( ! is_user_logged_in() ) {
		$error_message .= '<a class="ee-roundish ee-orange ee-button float-right ee-wpuser-login-button" href="' . wp_login_url( get_permalink() ) . '">' . __( 'Forgotten Password', 'event_espresso' ) . '</a>';
	}
}
add_action( 'EED_WP_Users_SPCO__verify_user_access__perform_email_user_match_check', 'my_add_forgotten_password_btn' );  

but it must be the wrong action, because it no longer gives the message.
Am I on the right track to just adding a forgotten password button next to the login for that warning? I’m aware my current code, even if it worked wouldn’t link the user to the forgotten password page but I was going to alter the link once it displayed.

Do you know the action I can use in this case to just add the button to that warning. That would save using a custom template and might be an easier away to achieve a forgotten password link?

Thanks.


Tony

  • Support Staff

June 2, 2016 at 11:48 am

EED_WP_Users_SPCO__verify_user_access__perform_email_user_match_check

Allows you to return either true or false based on the $spco and $registration object and determines if the email/user check should be performed, it is not what you need here. (You could use the other, but its more complicated the loading your own template)

I’m guessing you have not had much experience with WP hooks previously? (which is fine if that’s the case) You’re close but not using the hooks correctly.

The first function you provided doesn’t actually do anything as your function is not hooked into the filter, I’d highly recommend taking read over this:

https://www.smashingmagazine.com/2011/10/definitive-guide-wordpress-hooks/

As learning to use hooks correctly will help with almost all of your modifications.

So the code here, should be something like this:

https://gist.github.com/Pebblo/f5d9bfd66439d99d9cbe37558ac4b947

That will load the template from your themes root directory.

Note that when requesting to override templates is it expected that you will keep up to date with any changes made within those templates to match our changes (plus you’re own) and we do not provide support for custom templates. (Although if we can we will advise on what we can see)


robbstcs

June 3, 2016 at 2:08 am

Thank you,

Nope, I’ve not been doing WordPress development for very long, I’ve only just started taking over from a colleague who used to deal with hooks and actions. Thanks for the guide and your code, it’s clearer to me now.


Tony

  • Support Staff

June 3, 2016 at 4:50 am

You’re most welcome.

The support post ‘user integration templates, child theme’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso