• Resolved thevisas

    (@thevisas)


    Hi,

    Since last TML update we are having issues with out wordpress site.
    Firstly, when logging as admin an error message “Sorry, you are not allowed to access this page.”is displayed. At this stage the error limited too ../wp-admin/index.php file. I can access other files under wp-admin and administer site to a certain degree. According to Siteground support the error is caused by TML plugin.
    Secondly, we are receiving wordpress emails regarding technical issues. Please, see details below.
    Error Details
    =============
    An error of type E_ERROR was caused in line 102 of the file /home/thevisas/public_html/wp-content/themes/smartscreen-child/functions.php. Error message: Uncaught Error: Call to undefined function tml_add_form_field() in /home/thevisas/public_html/wp-content/themes/smartscreen-child/functions.php:102
    Stack trace:
    #0 /home/thevisas/public_html/wp-includes/class-wp-hook.php(286): add_gdpr_checkbox_to_tml_register_form(”)
    #1 /home/thevisas/public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
    #2 /home/thevisas/public_html/wp-includes/plugin.php(465): WP_Hook->do_action(Array)
    #3 /home/thevisas/public_html/wp-settings.php(525): do_action(‘init’)
    #4 /home/thevisas/public_html/wp-config.php(98): require_once(‘/home/thevisas/…’)
    #5 /home/thevisas/public_html/wp-load.php(37): require_once(‘/home/thevisas/…’)
    #6 /home/thevisas/public_html/wp-admin/admin.php(34): require_once(‘/home/thevisas/…’)
    #7 /home/thevisas/public_html/wp-admin/index.php(10): require_once(‘/home/thevisas/…’)
    #8 {main}
    thrown

    Could you, please, advise what if anything can be done to fix these errors.

    Kind regards, Vitali.

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Is the plugin active?

    Try reinstalling it (remove the entire plugin folder using FTP, then install from the repository again). Could be an incomplete/corrupt installation.

    Thread Starter thevisas

    (@thevisas)

    Thank you for your response.
    The plugin is active and operational. The GDRP code in functions.php also appear to be operational:
    //Registration Form GDRP
    function add_gdpr_checkbox_to_tml_register_form() {
    tml_add_form_field( ‘register’, ‘accept_terms’, array(
    ‘type’ => ‘checkbox’,
    ‘label’ => ‘By registering I agree with the storage and handling of my data by The Visas of OZ. Privacy policy‘,
    ‘value’ => ‘1’,
    ‘checked’ => tml_get_request_value( ‘accept_terms’, ‘post’ ),
    ‘priority’ => 30,
    ) );
    }
    add_action( ‘init’, ‘add_gdpr_checkbox_to_tml_register_form’ );
    function validate_gdpr_checkbox_on_registration( $errors ) {
    if ( ! tml_get_request_value( ‘accept_terms’, ‘post’ ) ) {
    $errors->add( ‘accept_terms’, ‘ERROR: Please, tick the checkbox.’ );
    }
    return $errors;
    }
    add_filter( ‘registration_errors’, ‘validate_gdpr_checkbox_on_registration’ );
    function save_gdpr_checkbox_on_registration( $user_id ) {
    if ( tml_get_request_value( ‘accept_terms’, ‘post’ ) ) {
    update_user_meta( $user_id, ‘accepted_terms’, 1 );
    }
    }
    add_action( ‘user_register’, ‘save_gdpr_checkbox_on_registration’ );

    Despite TML working, we were randomly receiving wordpress emails re technical issues as per previous message.

    Have reinstalled TML plugin and we’ll let you know if wordpress continues to experience technical errors.

    As for issues related to access to ../wp-admin/index.php, it does not seem to be TML related as when TML was disabled prior to reinstall the issues were still present.

    Regards, Vitali.

    Your code seems to make sense, but I have no experience adding fields, so not sure. My only through was related to the action handle, i.e. whether or not the function is declared when ‘init’ is triggered, but that’s likely.

    To be sure, you can wrap the call to tml_add_form_field() with if ( function_exists( 'tml_add_form_field' ) ) { /* call to function */ }

    Some access errors are due to not having a valid “nonce”. Others could be related to firewall rules or a security plugin.

    Thread Starter thevisas

    (@thevisas)

    Thanks again for quick response.

    The code in use is copied from TML website knowledgeable or FAQ and just modified slightly with custom GDRP message. So far it has been working OK.

    The errors started to appear after wordpress 5.2 that has a built-in feature that detects when a plugin or theme causes a fatal error and sends notification.

    Will monitor after TML reinstall and will try “if ( function_exists” if new errors are received.

    Regards, Vitali.

    Plugin Author Jeff Farthing

    (@jfarthing84)

    Can you give the entire context of code that encompasses line 102 of the file /home/thevisas/public_html/wp-content/themes/smartscreen-child/functions.php?

    Please wrap code in backticks or use the code button above the reply box.

    Thread Starter thevisas

    (@thevisas)

    Hi Jeff,
    Please, see the code below.

    //Registration Form GDRP
    function add_gdpr_checkbox_to_tml_register_form() {
    	tml_add_form_field( 'register', 'accept_terms', array(
    		'type' => 'checkbox',
    		'label' => 'By registering I agree with the storage and handling of my data by The Visas of OZ. <a target="_blank" href="/privacy/">Privacy policy</a>',
    		'value' => '1',
    		'checked' => tml_get_request_value( 'accept_terms', 'post' ),
    		'priority' => 30,
    	) );
    }
    add_action( 'init', 'add_gdpr_checkbox_to_tml_register_form' );
    function validate_gdpr_checkbox_on_registration( $errors ) {
    	if ( ! tml_get_request_value( 'accept_terms', 'post' ) ) {
    		$errors->add( 'accept_terms', '<strong>ERROR</strong>: Please, tick the checkbox.' );
    	}
    	return $errors;
    }
    add_filter( 'registration_errors', 'validate_gdpr_checkbox_on_registration' );
    function save_gdpr_checkbox_on_registration( $user_id ) {
    	if ( tml_get_request_value( 'accept_terms', 'post' ) ) {
    		update_user_meta( $user_id, 'accepted_terms', 1 );
    	}
    }
    add_action( 'user_register', 'save_gdpr_checkbox_on_registration' );
    Plugin Author Jeff Farthing

    (@jfarthing84)

    Which TML version are you using?

    Thread Starter thevisas

    (@thevisas)

    Theme My Login Version 7.0.15
    Theme My Login Social Version 1.0.2

    Plugin Author Jeff Farthing

    (@jfarthing84)

    Since you are a paying customer, you should be reaching out to us via https://thememylogin.com/support.

    Thread Starter thevisas

    (@thevisas)

    Would you like me to resubmit this request via https://thememylogin.com/support?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘TML updates and function tml_add_form_field’ is closed to new replies.