• I have set up a members site where members only have access to their profile page, everything else is hidden.

    The members have no idea of basic html so I need to add a basic version of TinyMCE (or similar to what we have here) to the text field on the profile page.

    I can’t see any switch to allow this. Is it possible?

    TIA.

Viewing 15 replies - 16 through 30 (of 32 total)
  • @bigbadboy

    Have you got in touch with the creator of Profiler? I’m still assuming that the issue you’re now experiencing is purely down to the plugin and it stripping htmlentities or something.

    You’ll need to check whether there are filters running on $output or $user_description – so reference where else they appear in the plugin code.

    I’ve been working on this extensively over the last 24 hours…. I have it working great. This is for WP vs 2.7 only…. and this is the scaled down version that is used in “press this”

    This goes in your functions.php file in your theme….I’m going to release an updated plugin for this feature later today…

    I found that the key is putting these 2 function calls in place….

    wp_enqueue_script(‘editor’);
    do_action(‘admin_print_scripts’);

    if ( (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/user-edit.php')) || (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/profile.php'))) {
    	add_action('admin_head', 'add_tinymce');
    	}
    
    	remove_filter('pre_user_description', 'wp_filter_kses');
    	add_filter('pre_user_description', 'wpautop');
    
    function add_tinymce() {
    
    if (function_exists('wp_tiny_mce')) {	
    
    	wp_enqueue_script('editor');
    	do_action('admin_print_scripts');
    
    		add_filter( 'teeny_mce_before_init', create_function( '$a', '
    			$a["theme"] = "advanced";
    			$a["skin"] = "wp_theme";
    			$a["height"] = "420";
    			$a["width"] = "400";
    			$a["onpageload"] = "";
    			$a["mode"] = "exact";
    			$a["elements"] = "description";
    			$a["editor_selector"] = "mceEditor";
    			$a["plugins"] = "safari,inlinepopups,wordpress";
    			$a["apply_source_formatting"] = "1";
    			$a["accessibility_focus"] = "1";
    			return $a;' ) );
    
    		wp_tiny_mce( true );
    	}
    }
    Thread Starter Lee Rickler

    (@bigbadboy)

    Alex – Yeah I’ve posted on his thread but so far nothing except possibly it’s a problem with WP itself as in the profile page has been set to strip all html.

    if so, how is this done?
    I’m not too clever a php coder but I cannot find the right info anywhere.

    brayne – yes, that helps getting tinymce on the profile page but it’s not carried through to the actual members’ details page.

    alexleonard is absolutely correct…. I didn’t pay attention to the comment made about using the plugin -> profiler. I was not using it. I installed it and took a look and made this change to the file profiler.php…

    At Line #464 I changed this….

    $output .= "<h3>About Me</h3>";
      $output .= "$user_description";

    To this…

    $output .= "<h3>About Me</h3>";
      $user_description = html_entity_decode($user_description);
      $output .= "$user_description";

    I have not notified the author because if he wanted to add this feature he would need to check a condition if using tinymce and such… You can limit the html allowed by making limits in tinymce but for now, making this change in profiler, the html will be read properly….

    Thread Starter Lee Rickler

    (@bigbadboy)

    Brayne – You is ‘Da Man’! It works exactly as needed.

    🙂

    Nice one @brayne I’ve been a bit busy today to go investigating plugins 🙁

    @bigbadboy Hope you’re all sorted now 🙂 It took a little while but got there in the end. I love these forums!

    Thread Starter Lee Rickler

    (@bigbadboy)

    This could be me but …
    Using FF (mac) I enter details in the field, save, view and everything is fine.
    I view on Safari (Mac) and IE7 – works fine
    BUT when I go to the admin in these 2 browsers, there’s nothing in the field.
    Tinymce bar is there and I can enter content but clicking save simply clears the field. BUT when I refresh the member’s page, the old content is still there.

    It could be me, Safari, IE or everything, not quite sure.

    Thread Starter Lee Rickler

    (@bigbadboy)

    OK. Just to update on this –
    Logged in as admin – no problem
    Logged in as subscriber – Description field is blank/ can make changes but changes are not carried through.
    BUT – view source and the content is visible in the content area …

    So:
    Logged in as admin – fine
    Logged in as user cannot view or edit description

    weird!

    UPDATE ON UPDATE:
    Removing the above code from functions.php and using the “Add TinyMce to Author Profile” plugin restores everything so there’s obviously a small visibility bug in this code:

    if ( (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/user-edit.php')) || (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/profile.php'))) {
    	add_action('admin_head', 'add_tinymce');
    	}
    
    	remove_filter('pre_user_description', 'wp_filter_kses');
    	add_filter('pre_user_description', 'wpautop');
    
    function add_tinymce() {
    
    if (function_exists('wp_tiny_mce')) {	
    
    	wp_enqueue_script('editor');
    	do_action('admin_print_scripts');
    
    		add_filter( 'teeny_mce_before_init', create_function( '$a', '
    			$a["theme"] = "advanced";
    			$a["skin"] = "wp_theme";
    			$a["height"] = "480";
    			$a["width"] = "300";
    			$a["onpageload"] = "";
    			$a["mode"] = "exact";
    			$a["elements"] = "description";
    			$a["editor_selector"] = "mceEditor";
    			$a["plugins"] = "safari,inlinepopups,wordpress";
    			$a["apply_source_formatting"] = "1";
    			$a["accessibility_focus"] = "1";
    			return $a;' ) );
    
    		wp_tiny_mce( true );
    	}
    }

    OK…. got weird…. I can guess that there was something going on with load order and changing from functions.php to the plugin has affected this..This can be changed in the action calls but it seems to be working out now…

    I did the same thing as bigbadboy and works just fine… All operations work as they should in FF, Safari, Opera on Mac. FF, Safari, IE7 on PC….IE6 however wont show the text in the Biographical Info field when tinyMCE is added… I blame IE6… It IS in the source code…just like bigbadboy wrote… but now not showing in that field when using IE6…unfortunately there is still 1 out 5 people using this browser so… I will still kick the tires on this..

    UPDATE – Working on it….. Realized this is a pretty lame solution if it only works for admins…. ;(.

    I have the tinyMCE editor working on the author “discription” field. But I added some costumfields with the register plus plugin. I copied the code:

    if ( (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/user-edit.php')) || (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/profile.php'))) {
    	add_action('admin_head', 'add_tinymce');
    }
    
    remove_filter('pre_user_description', 'wp_filter_kses');
    add_filter('pre_user_description', 'wpautop');
    
    function add_tinymce() {
    
    if (function_exists('wp_tiny_mce')) {	
    
    		add_filter( 'teeny_mce_before_init', create_function( '$a', '$a["width"] = "440"; $a["height"] = "400"; $a["onpageload"] = ""; $a["mode"] = "exact"; $a["elements"] = "description"; $a["editor_selector"] = "mceEditor"; return $a;' ) );
    		wp_tiny_mce( true );
    
    	}
    }

    Then renamed the “discription” element to my customfield name. That works fine. But I added more fields. I can’t get it working.

    How can I add the tinyMCE editor to multiple customfields?

    Hey jobmeer,

    be sure to read what bigbadboy was writing…. check the code with a “regular” user compared to an “administrator”

    This code works for both…..bigbadboy… you want to test it and let me know?? I tried this in said plugin and in functions.php and works in both….I was utilizing this parameter – $a[“plugins”] = “safari,inlinepopups,wordpress”;
    And it was causing it to not work with a regular subscriber… Also some of the above code uses hard coding the javascript file tiny_mce.js and it would take sooo long for the page to load this is the best solution I have found…

    if ( (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/user-edit.php')) || (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/profile.php'))) {
    	add_action('admin_head', 'add_tinymce');
    	}
    
    	remove_filter('pre_user_description', 'wp_filter_kses');
    	add_filter('pre_user_description', 'wpautop');
    
    function add_tinymce() {
    
    if (function_exists('wp_tiny_mce')) {	
    
      wp_enqueue_script('editor');  // This is the key to make it work...
      do_action('admin_print_scripts'); // This prints it in the proper place in the <head>
    
    		add_filter( 'teeny_mce_before_init', create_function( '$a', '
    			$a["theme"] = "advanced";
    			$a["skin"] = "wp_theme";
    			$a["height"] = "420";
    			$a["width"] = "400";
    			$a["onpageload"] = "";
    			$a["mode"] = "exact";
    			$a["elements"] = "description";
    			return $a;' ) );
    		wp_tiny_mce( true );
    	}
    }

    I made a dupe entry… sorry

    Question…

    Do WordPress plugins, shortcodes and filters work in TinyMCE on profile pages?

    Also, what is the preferred method everyone is using?

    There’s about 2 or 3 solutions posted in this thread, which one is working for you guys?

    I have tried this with no success on version 2.7. I wrote a function to display it… This seems to be the only way I could get it to work:

    function get_WYSIWYG($id='content',$name='content',$value=''){
    	$editor =<<<HTML
    				<script type="text/javascript" src="/wp-includes/js/tinymce/tiny_mce.js"></script>
    				<script type="text/javascript">
    					<!--
    					tinyMCE.init({
    					theme : "advanced",
    					skin:"wp_theme",
    					theme_advanced_buttons1:"bold,italic,strikethrough,underline,separator,bullist,numlist,outdent,indent,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,separator,styleprops,separator,separator,spellchecker,search,separator,fullscreen,wp_adv",
    					theme_advanced_buttons2:"fontsizeselect,formatselect,pastetext,pasteword,removeformat,separator,charmap,print,separator,forecolor,emotions,separator,sup,sub,separator,undo,redo,attribs,wp_help",
    					theme_advanced_buttons3:"",
    					theme_advanced_buttons4:"",
    					language:"en",
    					spellchecker_languages:"+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv",
    					theme_advanced_toolbar_location:"top",
    					theme_advanced_toolbar_align:"left",
    					theme_advanced_statusbar_location:"bottom",
    					theme_advanced_resizing:"1",
    					theme_advanced_resize_horizontal:"",
    					dialog_type:"modal",
    					relative_urls:"",
    					remove_script_host:"",
    					convert_urls:"", apply_source_formatting:"", remove_linebreaks:"1", paste_convert_middot_lists:"1", paste_remove_spans:"1",
    					paste_remove_styles:"1",
    					gecko_spellcheck:"1",
    					entities:"38,amp,60,lt,62,gt",
    					accessibility_focus:"1", tab_focus:":prev,:next",
    					wpeditimage_disable_captions:"",
    					plugins:"safari,inlinepopups,autosave,spellchecker,paste,wordpress,fullscreen,-emotions,-print,-searchreplace,-xhtmlxtras,-advlink,",
    					mode : "exact",
    					elements : "{$id}",
    					width : "565",
    					height : "200"
    					});
    					-->
    				</script>
    				<textarea id="{$id}" name="{$name}">{$value}</textarea>
    HTML;
    return $editor;
    }

    Now any time I need the editor, I just echo get_WYSIWYG($id,$name,$value);

    hope that helps anyone that was having the same issue.

Viewing 15 replies - 16 through 30 (of 32 total)
  • The topic ‘TinyMCE on Profile page’ is closed to new replies.