Simplified blog creation – blogname generated from Blog Title
-
I’m trying to simplify blog creation. This customized version of the form works surprisingly well:
function custom_signup_show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
global $current_site;
?>
<div id="blog-details-fields">
<input name="blogname" type="text" id="blogname" value="<? echo $blogname = str_replace(' ', '', strtolower(wp_specialchars($blog_title, 1))); ?>" maxlength="50" />
<label for="blog_title"><?php _e( 'Blog Title:', 'buddypress' ) ?></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).'" /></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);
}It’s two fields. When you put a ‘Blog Title’ in the second field and click ‘Create Blog’, you’re returning to the same form, but with ‘blogtitle’ added to the first field.
If you hit ‘Create Blog’ again, the blog is created at thewebsite.com/blogtitle.
It works, but as it is it’s a bit silly and unexpected. Does anyone have suggestions how to finish this?
My original plan was to make the first input field hidden. Then you only have one field: blog title + button: Go!
But you’d still have to hit the ‘Create Blog’ button twice. Or is there a trick to make it a double strenght click?
Another solution would be to have a message appear on the first click: “you’re URL will be… confirm?” But then you’d have to tell the user not to put something in the first field…
Should I replace the ‘echo’ in this line:
<? echo $blogname = str_replace(' ', '', strtolower(wp_specialchars($blog_title, 1))); ?>
with something else that immediately sends the value to the rest of the script, without first having to display it in the field? Perhaps ‘return’?
To a real PHP coder the solution is probably obvious. Please share it, spare me endless fruitless experiments. (It’s now close to midnight, have to stop myself…)
- The topic ‘Simplified blog creation – blogname generated from Blog Title’ is closed to new replies.