Support

Account

Home Forums Front-end Issues TinyMCE editor on front end causing JS error for non-admins

Helping

TinyMCE editor on front end causing JS error for non-admins

  • I’ve got an ACF form that I’m trying to integrate with the profile form of MemberPress. There’s a hook in MP within the main form field, so I’m adding an acf_form in there with form=false and post_id=”user_XXX” as well as return = false. I’ve also got my own hidden field which I use to trigger acf_form_head(), before memberpress saves its own data and reloads the page.

    It all works wonderfully for administrators. It’s genius!

    But for a custom role (essentially a custom subscriber role), they hit an error. Debug log is not particularly helpful:

    https://goo.gl/ajRmlN

    Here is the code I am using, this file is included on plugins_loaded.

    <?php
    
    if ( !defined('ABSPATH') ) return;
    
    function wcd_add_user_form_to_memberpress_profile_fields() {
    	$args = array(
    		/* The post ID to load data from and save data to. */
    		'post_id' => 'user_' . get_current_user_id(),
    
    		/* An array of field group IDs/keys to display in this form */
    		'field_groups' => array( 'group_57dcee280022a' ),
    		
    		/* Whether or not to create a form element. */
    		'form' => false,
    
    		/* The URL to be redirected to after the form is submit.*/
    		'return' => false,
    	);
    
    	acf_form( $args );
    
    	// Include custom action field so we know if we should manually trigger acf_form_head after submission.
    	echo '<input type="hidden" name="wcd-mepr-save-acf" value="1">';
    	
    	// Required JS templates for ACF uploader
    	add_action( 'get_footer', 'wcd_add_acf_prerequisites_for_memberpress_form' );
    }
    add_action( 'mepr-account-home-fields', 'wcd_add_user_form_to_memberpress_profile_fields' );
    
    // Enqueues the media uploader resources
    function wcd_add_acf_prerequisites_for_memberpress_form() {
    	acf_enqueue_uploader();
    }
    
    // Save ACF fields that were added to the memberpress form. This must happen before MemberPress saves their own data, because they redirect.
    function wcd_save_memberpress_profile_early() {
    	if ( isset($_REQUEST['wcd-mepr-save-acf']) ) {
    		acf_form_head();
    	}
    }
    add_action( 'init', 'wcd_save_memberpress_profile_early', 2 );

    Here are the field groups (three of them are just used for clone fields):

    https://goo.gl/Q6CBLM

  • Seems to come from: add_action( 'get_footer', 'wcd_add_acf_prerequisites_for_memberpress_form' );

    After changing tinymce to text area, and image field to a text field, the error goes away. For some reason – maybe related – none of the clone fields work in either situation. Everything works as an administrator, though.

    Still stumped. Now I have two serious issues. Clone fields are broken, and wyswig is broken.

    Here’s a screenshot of the form basics. See the phone field doesn’t have anything on the right? https://goo.gl/ddQTGb

    Any ideas? I’ve tried disabling other plugins to no avail. Unless it’s memberpress, but I need that for this system to work anyway.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.