Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 25 replies - 451 through 475 (of 690 total)
  • @peterverkooijen

    Participant

    Alternative solution: Use the following Javascript to generate a username on typing:

    function copyinputuser()
    {
    var tmp = document.getElementById('field_1').value;
    tmp = tmp.toLowerCase().replace(/^\s+|\s+$/g, "").replace(/[_|\s]+/g, "");
    tmp = tmp.replace(/[^a-z0-9-]+/g, "").replace(/[-]+/g, "").replace(/^-+|-+$/g, "");
    document.getElementById('user_name').value = tmp;
    }

    And then add onkeyup=”copyinputuser()” to the field_1 input tag, which requires an ugly hack in a core file.

    @peterverkooijen

    Participant

    The hack in function get_edit_html works.

    I had to slightly edit the javascript. ‘-‘ is not accepted in usernames:

    function copyinputuser()
    {
    var tmp = document.getElementById('field_1').value;
    tmp = tmp.toLowerCase().replace(/^\s+|\s+$/g, "").replace(/[_|\s]+/g, "");
    tmp = tmp.replace(/[^a-z0-9-]+/g, "").replace(/[-]+/g, "").replace(/^-+|-+$/g, "");
    document.getElementById('user_name').value = tmp;
    }

    @peterverkooijen

    Participant

    I see the html for the xprofile input fields is in function get_edit_html in bp-xprofile-classes.php:

    switch ( $this->type ) {
    case 'textbox':
    $html .= '<div class="signup-field">';
    $html .= '<label class="signup-label" for="field_' . $this->id . '">' . $asterisk . $this->name . ':</label>';
    $html .= $this->message . '<input type="text" name="field_' . $this->id . '" id="field_' . $this->id . '" value="' . attribute_escape( $this->data->value ) . '" />';
    $html .= '<span class="signup-description">' . $this->desc . '</span>';
    $html .= '</div>';
    break;

    So I guess I could add onkeyup=”copyinput()” there, but then all xprofile fields will get that. Would that mess up the system? The Javascript refers to the fields by ID.

    According to Jeff Sayre this method will be deprecated in version 1.1, but I need a temporary solution before I make the switch.

    Trying that now…

    @peterverkooijen

    Participant

    Success! Solution found here.

    The Javascript:

    <script type = "text/javascript">
    function copyinput()
    {
    var tmp = document.getElementById('blog_title').value;
    tmp = tmp.toLowerCase().replace(/^s+|s+$/g, "").replace(/[_|s]+/g, "");
    tmp = tmp.replace(/[^a-z0-9-]+/g, "").replace(/[-]+/g, "-").replace(/^-+|-+$/g, "");
    document.getElementById('blogname').value = tmp;
    }
    </script>

    The customized function:

    function custom_signup_show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
    global $current_site;

    ?>
    <div id="blog-details-fields">

    <label for="blog_title">Blog title</label>
    <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>
    <p class="error"><?php echo $errmsg ?></p>
    <?php }
    echo '<input name="blog_title" type="text" id="blog_title" value="'.wp_specialchars($blog_title, 1).'" maxlength="24" onkeyup="copyinput()"/></p>';

    // Blog name
    if ( 'no' == constant( "VHOST" ) )
    echo '<label for="blogname">' . __('Blog Name:', 'buddypress') . '</label>';
    else
    echo '<label for="blogname">' . __('Blog Domain:', 'buddypress') . '</label>';

    if ( $errmsg = $errors->get_error_message('blogname') ) { ?>
    <p class="error"><?php echo $errmsg ?></p>
    <?php }

    if ( 'no' == constant( "VHOST" ) ) {
    echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><br />';
    } else {
    echo '<input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><span class="suffix_address">.' . $current_site->domain . $current_site->path . '</span><br />';
    }

    if ( !is_user_logged_in() ) {
    echo '<p class="help-text">';
    print '(<strong>' . __( 'Your address will be ', 'buddypress' );
    if( 'no' == constant( "VHOST" ) ) {
    print $current_site->domain . $current_site->path . __( 'blogname', 'buddypress' );
    } else {
    print __( 'domain.', 'buddypress' ) . $current_site->domain . $current_site->path;
    }
    echo '</strong>. ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed so choose carefully!)', 'buddypress' ) . '</p>';
    echo '</p>';
    }
    ?>
    <p>
    <label for="blog_public_on"><?php _e( 'I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.', 'buddypress' ); ?> </label>
    <label class="checkbox" for="blog_public_on">
    <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if( !isset( $_POST['blog_public'] ) || '1' == $_POST['blog_public'] ) { ?>checked="checked"<?php } ?> />
     <?php _e( 'Yes', 'buddypress' ); ?>
    </label>
    <label class="checkbox" for="blog_public_off">
    <input type="radio" id="blog_public_off" name="blog_public" value="0" <?php if( isset( $_POST['blog_public'] ) && '0' == $_POST['blog_public'] ) { ?>checked="checked"<?php } ?> />
     <?php _e( 'No', 'buddypress' ); ?>
    </label>
    </p>
    </div>
    <?php
    do_action('signup_blogform', $errors);
    }

    What this does:

    When the user starts typing the blog title – limited to 24 chars – the Javascript dynamically fills in the blogname for the URL.

    The user can manually change the blogname if he/she wants. Not sure how that would work out…

    You could probably also hide the blogname field, either through type=”hidden” or CSS. Haven’t tested all these options yet.

    But imho this looks like a very versatile solution. :-)

    Or have I overlooked some critical issues? Comments very much appreciated!

    @peterverkooijen

    Participant

    Another approach. With this bit of Javascript you can copy the input from blog_title to blogname as you type:

    <script type = "text/javascript">
    function copyIt() {
    x = document.getElementById("blog_title").value;
    document.getElementById("blogname").value = x;
    }
    </script>

    ...

    <input name="blog_title" type="text" id="blog_title" value="'.wp_specialchars($blog_title, 1).'" maxlength="24" onkeyup="copyIt()"/>

    <input name="blogname" type="text" id="blogname" value="" />

    Now if I could figure out how to sanitize/lowercase the input between blog_title and blogname, this could be a really cool solution.

    A big if again… Suggestions very much appreciated!

    @peterverkooijen

    Participant

    Removing the blogname field from the form and adding this to the next (?) function also does not work:

    function bp_core_signup_validate_blog_form() {
    $user = '';
    if ( is_user_logged_in() )
    $user = wp_get_current_user();

    $_POST['blogname'] = preg_replace('/[^a-z0-9]/i', '', str_replace(' ', '', strtolower(wp_specialchars($blog_title, 1))));

    return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user);
    }

    Is there any way to make that work or is it another dead end?

    @peterverkooijen

    Participant

    This also does not work…:

    function autoblogname() {
    $blogname = preg_replace('/[^a-z0-9]/i', '', str_replace(' ', '', strtolower(wp_specialchars($blog_title, 1))));
    return $blogname;
    }

    ...

    echo '<input name="blog_title" type="text" id="blog_title" value="'.wp_specialchars($blog_title, 1).'" maxlength="24" /></p>';
    ?>
    <input name="blogname" type="text" id="blogname" value="<? $blogname = autoblogname(); ?>" />

    Help! :-(

    @peterverkooijen

    Participant

    This also does not work…

    echo '<input name="blog_title" type="text" id="blog_title" value="'.wp_specialchars($blog_title, 1).'" maxlength="24" /></p>';
    $blogname = preg_replace('/[^a-z0-9]/i', '', str_replace(' ', '', strtolower(wp_specialchars($blog_title, 1))));
    $_POST['blogname'] = $blogname;

    Please, if anyone knows how to do this, put me out of my misery.

    @peterverkooijen

    Participant

    This doesn’t work either…:

    ...
    echo '<input name="blog_title" type="text" id="blog_title" value="'.wp_specialchars($blog_title, 1).'" /></p>';

    $blogname = preg_replace('/[^a-z0-9]/i', '', str_replace(' ', '', strtolower(wp_specialchars($blog_title, 1))));

    ?>

    <input name="blogname" type="text" id="blogname" value="<? wp_specialchars($blogname, 1); ?>" maxlength="50" />
    ...

    @peterverkooijen

    Participant

    Latest attempt didn’t work… :-(

    Should I do something with $_POST['blogname']?

    Any ideas very much appreciated!

    BTW, improved cleanup:

    $blogname = preg_replace('/[^a-z0-9]/i', '', str_replace(' ', '', strtolower(wp_specialchars($blog_title, 1))));

    @peterverkooijen

    Participant

    Good point r-a-y! I’ll put a limit on the number of characters for the title field. Problem solved!

    It’s a matter of choice of course. I try to follow the less is more school of interface design, think Apple – I use pc myself, not a Mac fanboy, just making a point.

    Does anybody know what I should use instead of ‘echo’ to send that value for blogname straight to the rest of the script?

    Or can I do something like this:

    <input name="blogname" type="hidden" id="blogname" value="$blogname" maxlength="50" />
    <?php
    $blogname = str_replace(' ', '', strtolower(wp_specialchars($blog_title, 1)));
    ?>

    I think I’ve already tried this, but it didn’t do anything. I’ll try again…

    @peterverkooijen

    Participant

    No, the problem is importing 180+ posts, most of them with object and embed tags.

    Initially I was hosting my own videos and I still want to keep that option. There doesn’t seem to be a plugin for that.

    And I’m a bit reluctant to fall back to yet another plugin for something that should be standard html. If it causes security issues, WP should come up with smarter ways to deal with them instead of just erasing 80% of my posts.

    If these plugins are so effective, has anyone integrated them with export/import, so that object/embed tags are automatically converted to safe tags?

    I’m happy to keep my own blog “unsafe” and block object/embed for other blogs on the system. If someone could fix Unfiltered MU so I can do that again, that would solve my headache.

    @peterverkooijen

    Participant

    Have you tried enabling the Unfiltered MU plugin in the blog in question before you imported your posts?

    Yes, of course. That used to work, but no longer.

    I’m not using object/embed in any BP component. My original question was about the blog as well. I’d posted the question here because I hadn’t seen the same problem in WP.

    @peterverkooijen

    Participant

    The Unfiltered MU plugin works for admins and editors in WordPress, but it depends what BP component you’re trying to use the embed/object tags in BP.

    The Unfiltered MU plugin did not work for importing blog posts anymore. I needed a way to import 180+ post, most of them with embedded video on Blip.tv.

    Yes, security is important, but if it wipes out 80% of my blog something’s gotta give.

    I’ll remove the code from kses.php and let the Unfiltered MU plugin take over for just the main blog. Or wouldn’t that work? Would I have to start all over again, manually remove 180+ messed up posts?

    How can I turn the object/embed tag stripping off in Buddypress’ main blog? I’m not trying to use the tags in a Buddypress component, only in the main blog. Or is that a component as well? Confused…

    Like Zenseeker, I couldn’t make sense of Burt Adsit’s solution.

    @peterverkooijen

    Participant

    Solved it by adding the following under ‘allowedposttags = array’ in kses.php:

    'object' => array (
    'id' => array (),
    'classid' => array (),
    'data' => array (),
    'type' => array (),
    'width' => array (),
    'height' => array (),
    'allowfullscreen' => array ()),
    'param' => array (
    'name' => array (),
    'value' => array ()),
    'embed' => array (
    'id' => array (),
    'style' => array (),
    'src' => array (),
    'type' => array (),
    'height' => array (),
    'width' => array (),
    'quality' => array (),
    'name' => array (),
    'flashvars' => array (),
    'allowscriptaccess' => array (),
    'allowfullscreen' => array ()),
    'script' => array (
    'type' => array ()),

    @peterverkooijen

    Participant

    No effect.

    I’ll just leave it on ‘newest’ for now. I think all that Ajax stuff needs a serious second look. It all breaks very easily. I also lost pagination somewhere along the way and I noticed you can’t just stick the members search tag in the profile page, for example.

    With Ajax the PHP, javascript and CSS are all intertwined. If I had a clearer picture how these pieces work they’d be easier to deal with, but I can’t even find the javascript for that search box. Probably hidden deep inside core files somewhere.

    @peterverkooijen

    Participant

    It also works fine with:

    <?php if ( bp_has_site_members( 'type=newest&per_page=10' ) ) : ?>

    But not with ‘random’.

    Bug?

    BTW, I apparently also lost pagination on the members directory somewhere along the way. Any ideas what could break that?

    @peterverkooijen

    Participant

    How do you mean using custom fields?

    I’m trying to import 180+ existing posts, most of them with embedded video.

    I still have to try Burt Adsit’s manual solution as a last resort, but if Unfiltered MU doesn’t work it’s unlikely code in bp-custom would work.

    @peterverkooijen

    Participant

    Found the culprit. I had replaced this in the members-loop.php:

    <?php if ( bp_has_site_members( 'type=active&per_page=10' ) ) : ?>

    with this:

    <?php if ( bp_has_site_members( 'type=random&per_page=10' ) ) : ?>

    But WHY does that break the Ajax search?!

    Or is ‘random’ not an accepted type? It did give the required result…

    @peterverkooijen

    Participant

    Running into this annoying problem again and the Unfiltered MU plugin no longer seems to work.

    @peterverkooijen

    Participant

    Thanks so much Paul Dixon!

    That looks like a good start. I need to spend some time on my day job, but will test/finish this as soon as possible…

    @peterverkooijen

    Participant

    Well, someone better write it!

    That’ll be me I’m afraid…

    I’ll look into it. I’ve added a css class=”hideinshame” to all the crap in user-edit.php as a temporary hack, but I’ll need a cleaner, more permanent solution.

    In reply to: Import existing user

    @peterverkooijen

    Participant

    Apparently Manoj Kumar’s very essential users import plugin does not work with the latest version:

    The Big K at 19:19 on 9 August 2009

    Hi Manoj,

    The plugin is not compatible with WPMU 2.8.3 & Buddypress 1.0.3. Could you please fix it.

    This is also the version of the plugin I’ve tried – I gave the wrong link earlier.

    In my installation the plugin worked for the essentials – username, email address – but nothing was added to meta in wp_signup and the xprofile fields.

    Next I’ll try it in a fresh install of Buddypress 1.0 RC… :-(

    In reply to: Import existing user

    @peterverkooijen

    Participant

    I really do appreciate all your hard work, Jeff Sayre!

    I don’t only post to beg for solutions. A lot of my posts are reminders for myself what I’m doing, what I have already tried and what issues I still need to solve.

    I imagine other regular web developers using Buddypress will run into many of the same issues I run into. Hopefully my threads and posts will be useful resources to them.

    The solution to this users import time-out issue is now available within the Buddypress forum. One more thing you hopefully don’t have to answer again in the future.

    My experience even put an approximate number on it. I think on the second attempt I’ll just split my list in half, import them as two batches of 300.

    In reply to: Import existing user

    @peterverkooijen

    Participant

    I’ve noticed the imported users have also been added to the mailing list via my bp-custom.php function.

    So the plugin actually “runs” the regular registration processes, including wpmu_activate_user? Whatever member registration custom code or plugin you have inbetween, this plugin takes it into account?

    That is pretty cool. :-)

Viewing 25 replies - 451 through 475 (of 690 total)
Skip to toolbar