Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $post = array(
- 'post_title'=>$_POST['firstname'] . $_POST['lastname'],
- 'post_type'=>'registration',
- 'post_content'=>'',
- 'post_status' => 'publish',
- );
- $registration_id = wp_insert_post();
- update_post_meta($registration_id, 'email', $_POST['email']);
- //wp_publish_post($registration_id);
- add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
- add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
- function my_show_extra_profile_fields( $user ) { ?>
- <h3>Extra profile information</h3>
- <table class="form-table">
- <tr>
- <th><label for="abn">ABN</label></th>
- <td>
- <input type="text" name="abn" id="abn" value="<?php echo esc_attr( get_the_author_meta( 'abn', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description">Please enter your abn num.</span>
- </td>
- </tr>
- <tr>
- <th><label for="abn">Business Name</label></th>
- <td>
- <input type="text" name="BusinessName" id="BusinessName" value="<?php echo esc_attr( get_the_author_meta( 'BusinessName', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description">Please enter your Business Name.</span>
- </td>
- </tr>
- <tr>
- <th><label for="abn">Business type</label></th>
- <td>
- <input type="text" name="Businesstype" id="Businesstype" value="<?php echo esc_attr( get_the_author_meta( 'Businesstype', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description">Please enter your Business type.</span>
- </td>
- </tr>
- </table>
- <?php }
- add_action( 'personal_options_update', 'my_save_extra_profile_fields' );
- add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' );
- function my_save_extra_profile_fields( $user_id ) {
- if ( !current_user_can( 'edit_user', $user_id ) )
- return false;
- /* Copy and paste this line for additional fields. Make sure to change 'twitter' to the field ID. */
- update_usermeta( $user_id, 'abn', $_POST['abn'] );
- update_usermeta( $user_id, 'BusinessName', $_POST['BusinessName'] );
- update_usermeta( $user_id, 'Businesstype', $_POST['Businesstype'] );
- }
- //add bulk action in registration post types
- add_filter('manage_edit-product_columns', 'my_extra_cake_columns');
- function my_extra_cake_columns($columns) {
- $columns['slices'] =__('Create User');
- return $columns;
- }
- add_action( 'personal_options_update', 'my_save_extra_profile_fields' );
- add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' );
- function my_save_extra_profile_fields( $user_id ) {
- if ( !current_user_can( 'edit_user', $user_id ) )
- return false;
- /* Copy and paste this line for additional fields. */
- update_usermeta( $user_id, 'abn', $_POST['abn'] );
- update_usermeta( $user_id, 'BusinessName', $_POST['BusinessName'] );
- update_usermeta( $user_id, 'Businesstype', $_POST['Businesstype'] );
- }
- add_action( 'manage_product_posts_custom_column', 'my_cake_column_content', 10, 2 );
- function my_cake_column_content( $column_name, $post_id ) {
- if ( 'slices' != $column_name )
- return;
- echo '<a href="#">Add as user</a>';
- }
- add_filter( 'manage_edit-product_sortable_columns', 'my_sortable_cake_column' );
- function my_sortable_cake_column( $columns ) {
- $columns['slices'] = 'slice';
- return $columns;
- }
- //How to Create User
- $fname = get_post_meta($post_id,'firstname',true);
- $lname = get_post_meta($post_id,'lastname',true);
- $email_address = get_post_meta($post_id,'email',true);
- $password = rand(); //create random password
- $user_id = wp_create_user( $email_address, $password, $email_address );
- // Set the nickname
- wp_update_user(
- array(
- 'ID' => $user_id,
- 'nickname' => $email_address,
- 'first_name' => $fname,
- 'last_name' => $lname
- )
- );
- // Set the role
- $user = new WP_User( $user_id );
- //delete that post
- wp_delete_post( $post_id );
- // Email the user
- wp_mail( $email_address, 'Welcome!', 'Your Password: ' . $password );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement