• I need to create profile page in admin with custom user fields (not only contact info, I know there are filters for that). Users on my site will be companies and not people, therefore I need to have profile page display fields like:

    Company name
    Address
    City

    Rather then:

    first name
    Last name
    Nickname
    Display name etc….

    Since I would like to do this without hardcoding the core files I came up with an idea.
    I created a plugin that creates New Profile menu item and copied te code from edit-user.php. I needed to delete lines where we call admin-header and admin-footer to make it work and also I added a piece of code from profile.php “define(‘IS_PROFILE_PAGE’, true);”

    Now, everything is working except I cannot get a new profile page to submit properly! The problem is in lines:

    <form id="your-profile" action="<?php echo esc_url( self_admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post"<?php do_action('user_edit_form_tag'); ?>>
    <?php wp_nonce_field('update-user_' . $user_id) ?>
    <?php if ( $wp_http_referer ) : ?>
    	<input type="hidden" name="wp_http_referer" value="<?php echo esc_url($wp_http_referer); ?>" />

    The thing is, when I change something on my New profile page it redirects me to profile.php, and when I change the parameter “form action=” to the New profile page the form does not get submitted at all.

    Any ideas?
    I have searched the whole web for a solution on hidding some profile elements and only thing I know for sure that many people are searching for the same thing. If someone would help me figure out the submitting issue, we could finish the plugin which creates custom edit-profile page!

Viewing 15 replies - 16 through 30 (of 35 total)
  • As you said, Croation it’s not a problem (I was just kidding :-D).

    I’ve added some fields to my custom profile and I’m working in some dinamic field checking via Jquery or similar.

    Your mention of ‘members’ plugin was very userfull for me, I was looking for something similar and it seems it has all that I need.

    Important for other people Image uploading wont’t work until you create a my-script.js file under wp-admin/plugins folder with this code:

    jQuery(document).ready(function() {
    
    jQuery('#upload_image_button').click(function() {
     formfield = jQuery('#upload_image').attr('name');
     tb_show('', 'media-upload.php?type=image&TB_iframe=true');
     return false;
    });
    
    window.send_to_editor = function(html) {
     imgurl = jQuery('img',html).attr('src');
     jQuery('#upload_image').val(imgurl);
     tb_remove();
    }
    
    });

    To use image uploading remember to click Upload image->Select file->(upload)->Insert image into post This adds an url (a direct link to image) in your field. Instead of a direct link I think it would be better to insert a reference to image and compose it after in frontend in order to make it independent of domain, I’ll take a look.

    See you!

    error code asimac2001

    Fatal error: Call to undefined function get_attachment_id_from_src() in /home/misionsa/public_html/demo/wp-content/plugins/add-contact/add-contact.php on line 112

    I copied the plugin code from above (without editing anything in it), uploaded to a new directory (…/plugins/custom-profile/custom-profile.php).

    Admin looks good: the menu item “Moji podaci” is there and the actual admin page and all the new input fields are there.

    However, upon clicking submit button, the new data entered isn’t being sent to the database and the page just refreshes to blank white screen.

    Then I click on a non-related menu item to clear and then back on the “Moji podaci” menu button and the new data I entered is not pre-populated in the fields (ie, not in the database). The normal default fields that I entered using the default edit profile page are pre-populated though.

    Any idea what I’m missing?

    thanx,
    fj

    mvanboordt

    (@mvanboordt)

    @frankjackson and @asimac2001.

    I came across the same problem. Left everything to the way is “should” be, but unfortunately.

    Is there anybody who found an answer?
    And BTW it might be usefull to tell everybody that you have to create the database yourself.

    Thnx,

    Thread Starter Andrej

    (@asimac2001)

    Hi guys,

    since this is not intended to be a plugin, I never compiled this script in a way it could be widely used out of the box. However, I took some time to translate it and do some minor adjustments so you can use it… I compiled it in a .rar file and You can download it here:
    https://www.megaupload.com/?d=H1TIZUAX

    It should work out of the box (tested on 3.2.1), and it creates page in administration called “My profile”. All the data is stored in user contact fields and can be used in a standard way in a template. In some near future when I have time I could create a plugin out of it with administration page on which You could define all the fields You want to use… but for now try to use the code available.

    mvanboordt

    (@mvanboordt)

    Thank you for the updated version.

    However I thought I could use this for every user.
    I guess I misunderstood.

    I am looking for a script where I can add companies and view it on the website per company.

    My mistake

    M

    Thread Starter Andrej

    (@asimac2001)

    @mvanboordt:

    Mate, you CAN use this scipt for every user, thats why it was written in a first place! Have a look at one of my client generated portals (real-estate web site): Nekretnine2.com
    This page is a list of companies using the site, if You click on a company you will get to Company page with all the data (about us, phone number, address, etc… even logo for those who use it).

    I suppose that is exactly what you are trying to do? WordPress is extremely powerfull tool if you know how to use it and a lot can be done quickly ?? I will be glad to help You with your site, let me give you some pointers first:

    – WordPress default file structure among all uses author.php file for displaying user info. Check this out: https://codex.www.ads-software.com/Author_Templates
    – Create author.php in Your theme, and create several users (companies) in your administration panel.
    – You can access “company site” by using author id: https://www.yoursite.com/?author=ID, example: https://nekretnine2.com/?author=86
    – Inside your author.php you can access and display all the data stored by my script using wordpress functions get_userdata and the_author_meta… check out the codex…

    Some eaxmple usage from my site:

    <?php
    $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
    $autor = $curauth->ID;
    $author_data = get_userdata( $autor );
    
    // Here we extract company data
    $Company= $author_data->Company;
    $Address= $author_data->Address;
    $logo = $author_data->Logo;
    $logo_src = wp_get_attachment_image_src( $logo, 'logo' );
    $City= $author_data->City;
    $Postal= $author_data->Postal;
    $telefon = $author_data->Telefon;
    $fax = $author_data->Fax;
    $onama = $author_data->description;
    $email = $author_data->user_email;
    $web = $author_data->user_url;
    ?>

    You can now echo this variables anywhere in your template… Hope this helps ??

    mvanboordt

    (@mvanboordt)

    Damn!!!

    That is exactly what I am trying to achieve.
    I am now going to read and understand the whole thing including the new links you gave me.

    If I have any questions which I probably have I’ll get back 2 you.

    Thnx this really helps.

    mvanboordt

    (@mvanboordt)

    I quess I don’t fully understand.

    I created a new template where I can show all my companies.
    However I can’t seem to get them on display.

    This is what I got sofar in the template:

    <?php
    /*
    Template Name: Bedrijven
    */
    ?>
    <?php
    $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
    $autor = $curauth->ID;
    $author_data = get_userdata( $autor );
    
    // Here we extract company data
    $Company= $author_data->Company;
    $Address= $author_data->Address;
    $logo = $author_data->Logo;
    $logo_src = wp_get_attachment_image_src( $logo, 'logo' );
    $City= $author_data->City;
    $Postal= $author_data->Postal;
    $Phone = $author_data->Phone;
    $Fax = $author_data->Fax;
    $onama = $author_data->description;
    $email = $author_data->user_email;
    $web = $author_data->user_url;
    ?>
    <?php get_header(); ?>
    <div id="primary">
    	<div id="content" role="main">
    	<h2>Bedrijven:</h2>
    	<ul>
    		<?php wp_list_authors('exclude_admin=0'); ?>
    
    	</ul>
    	</div>
    </div>
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Hope you can assist me

    Thread Starter Andrej

    (@asimac2001)

    Try using this for your page template… this should display all “companies” with the link to their author pages.

    <?php get_header(); ?>
    <?php
    /*
    Template Name: Bedrijven
    */
    ?>
    <?php
    $szSort = "user_registered";
    $aUsersID = $wpdb->get_col( $wpdb->prepare(
    	"SELECT $wpdb->users.ID FROM $wpdb->users ORDER BY %s ASC"
    	, $szSort ));
    ?>
    <div id="primary">
    	<div id="content" role="main">
    	<h2>Bedrijven:</h2>
    	<ul>
    <?php
    foreach ( $aUsersID as $iUserID ) {
    	$user_info = get_userdata( $iUserID );
    ?>
                   <li><a href="<?php echo home_url(); ?>/?author=<?php echo $user_info->ID; ?>"><?php echo $user_info->Company; ?></a></li>
    <?php
    
    }
    ?>
    </ul>
    </div>
    </div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Also, create file called author.php and put this in it:

    <?php get_header(); ?>
    <?php
    $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
    $autor = $curauth->ID;
    $author_data = get_userdata( $autor );
    
    // Here we extract company data
    $Company= $author_data->Company;
    $Address= $author_data->Address;
    $logo = $author_data->Logo;
    $logo_src = wp_get_attachment_image_src( $logo, 'logo' );
    $City= $author_data->City;
    $Postal= $author_data->Postal;
    $Phone = $author_data->Phone;
    $Fax = $author_data->Fax;
    $onama = $author_data->description;
    $email = $author_data->user_email;
    $web = $author_data->user_url;
    ?>
    
    <div id="primary">
    	<div id="content" role="main">
    	<p>Our company is called <?php echo $Company; ?> and our phone number is: <?php echo $Phone; ?></p>
    	</div>
    </div>
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Would be helpfull if you provided a link to your website where you are putting this code for further assistance…

    mvanboordt

    (@mvanboordt)

    Dude!!!!

    Wow big thnx. This works like a charm.
    Check test.besidespurple.nl

    So now I just have to replace the names with the logo’s and then some onther functions like:
    – getting all companies to be devided under a letter. So you can search on a letter to get all the companies starting with that letter
    – make sure nobody can eddit the page.
    – and a whole lot more, but this was the very base.

    Thnx a LOT

    Just what I was looking for.

    @asimac2001, can this be used on multi site installation?
    That i what I have. If yes do I need to put this in mu-plugins?

    Thanks.

    Ok I tested on my multisite and it works fine if activated on main blog but network activating or placing in mu-plugins gives white screen.

    Anyone has suggestions?

    Thank you.

    Ok I guess I could include the function to replace profile fields inside every theme available on multisite for now.

    But I got another question,

    Noticed The new fields in standard profile and ones in New “My profile” page are they all same. If update on one page, it’s updated on other too.

    I essentially want the new profile fields on standard profile page but would like to also add “Upload logo” to standard edit profile page (just like it is on “My profile” page – actually would change to Upload avatar).

    Than transform new “My profile” page to be a page for the Company (user’s company) with all new fields ids. It still attaches to user but they are different fields from standard profile page.

    How should I go about this?

    Any help is greatly appreciated.

    Thread Starter Andrej

    (@asimac2001)

    Hi Imcobar,

    I cannot help You with MU since I never tested it, to be honest i never even installed wordpress MU. This script of mine was created for a specific purpose and it is not a plugin at all… however it serves to lot of people as quite a good base for some of their own projects.

    When I wrote the script I used the wordpress ‘user contact fields’ only because I could then easily manipulate data throughout my theme… I believe that You could easily create another MySQL table specificaly for user data you want to save.

    The other and maybe more simple option would be to duplicate my plugin and create 2 custom “Profile pages”, one for complayn data, and other for user. You would have to make sure that variables used are not the same… I think you could easily include changing avatar picture and password in other profile page.

    So basically, You would store all data in default “profile” which would be hidden for end user, and display that same data on 2 different custom profile pages…

    Hope that helps and I wish you best of luck ??

Viewing 15 replies - 16 through 30 (of 35 total)
  • The topic ‘Custom edit profile admin page’ is closed to new replies.