Skip to:
Content

Opened 4 years ago

Closed 4 years ago

#5674 closed enhancement (fixed)

Need actions on Add/Edit admin screens for xProfile component

Reported by: slaFFik Owned by: boonebgorges
Milestone: 2.1 Priority: normal
Severity: normal Version:
Component: Extended Profile Keywords: has-patch
Cc: lmoffereins@…

Description

http://screencast.com/t/oVS1MUuFzm

I would like to be able to add own metaboxes to display there custom options and process them differently on field save action.

And Submit area (where Cancel and Save buttons) should have some actions too.

Attachments (4)

5674.01.patch (5.5 KB) - added by Offereins 4 years ago.
XProfile admin metabox hooks
5674.01.diff (5.5 KB) - added by Offereins 4 years ago.
Idem
5674.02.patch (1.9 KB) - added by boonebgorges 4 years ago.
5674.03.patch (3.8 KB) - added by boonebgorges 4 years ago.

Download all attachments as: .zip

Change History (17)

#1 @DJPaul
4 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

#2 @Offereins
4 years ago

  • Cc lmoffereins@… added

What would a proper patch for this enhancement require? A complete redo of the admin pages to make use of the metaboxes API (as do the groups admin pages)? Or would some hooks in appropriate places be okay for now? This is a must have for devs to make use of xProfile metadata.

Edit: it appears that JJJ already said so 2 years ago: [6297].

Last edited 4 years ago by Offereins (previous) (diff)

#3 @boonebgorges
4 years ago

A complete redo of the admin pages to make use of the metaboxes API (as do the groups admin pages)? Or would some hooks in appropriate places be okay for now?

Hooks are fine for now. Using the metabox API or something like that would be nifty, but not necessary for the moment. (Also, might want to talk with DJPaul before going to those lengths - he has ideas about different kinds of rewrites of this interface.)

#4 @DJPaul
4 years ago

Yeah, adding actions is probably the best thing to do now, and that kind of small change could make it into the next BuddyPress release, and is something we should be able to keep compatibility for going forward.

@Offereins
4 years ago

XProfile admin metabox hooks

@Offereins
4 years ago

Idem

#5 @Offereins
4 years ago

  • Keywords has-patch added; needs-patch removed

Aside: Not sure why both .patch and .diff files show up broken and have additional empty lines. It should still work I hope. It's my first ever patch.

The patch adds both in BP_XProfile_Group::render_admin_form() and BP_XProfile_Field::render_admin_form() several hooks, inspired by wp-admin/edit-form-advanced.php and wp-admin/includes/metaboxes.php:

  • xprofile_group|field_before_submitbox before the submit metabox
  • xprofile_group|field_submitbox_start within the submit metabox before the publishing actions
  • xprofile_group|field_after_submitbox after the submit metabox
  • xprofile_group|field_edit_form_advanced in the second metabox container postbox-container-2

All hooks are provided with the current object and received some minor documentation. I hope it can still pass before the 2.1 release.

PS. The hooks don't do any auto-metaboxing, so you still have to build your own metabox HTML, like so:

<div class="postbox">
   <h3>Title</h3>
   <div class="inside">
       <p>Content</p>
   </div>
</div>
Last edited 4 years ago by Offereins (previous) (diff)

#6 @DJPaul
4 years ago

Thanks Offereins. :)

Odd that the patch files do appear a little on the corrupt side when viewed in Trac (I haven't tried applying them yet). How did you generate the patch files?

#7 @Offereins
4 years ago

My pleasure :)

Working in Sublime Text 2 I duplicated the source file, edited it and used the native file diff action. After comparison with existing patch files that already reside here in trac for other tickets, I tweaked the diff header a little to mimic those and saved it as .diff/.patch. I think it has something to do with line endings and machine code or something like that.

I know people use SVN around here, but I was hoping to find a different route instead of having to learn new software on my already not-so-fast machine.

#8 @boonebgorges
4 years ago

  • Milestone changed from Future Release to 2.1

I think it's the fact that you're using diff rather than svn diff. It's not translating the line endings and filepaths from Windows to Linux. I know it can be a bit of a pain, but if you can get svn up and running for generating patches, it would make our lives much easier (especially for patches that make more modifications of existing code than this one does!)

I'm taking care of the patch manually right now. Looks mostly very good. One quibble is that I don't think that the postbox-container-2 div makes sense for us at the moment; WP includes this because they natively support the output of metaboxes in this section using the API (add_meta_box( ... 'advanced' ... )) but we don't. It'd only make sense if we did do_action( 'edit_form_advanced' ) and then ensured that we only caught the metaboxes registered for this page, but this is more of a change than I want to endeavor this close to our beta release.

I'm also going to move 'xprofile_group_after_submitbox' outside of the 'submitdiv' element, so it better parallels 'xprofile_group_before_submitbox'.

#9 @boonebgorges
4 years ago

5674.02.patch is posted for a sanity check :)

#10 @Offereins
4 years ago

Thanks for the check. It seems 5674.02 is leaving out the hooks in BP_XProfile_Field. Is that on purpose?

#11 @boonebgorges
4 years ago

They didn't show up the first time I was manually examining the diff for some reason. See 5674.03.patch.

#12 @Offereins
4 years ago

For a great implementation of this ticket and the new bp_xprofile_get_groups() I've build a nice plugin that makes use of xprofile meta: BP XProfile For User Groups (requires trunk). Hope this shows the value of the latest patch.

#13 @boonebgorges
4 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 8801:

Add action hooks in the xprofile admin interface

Fixes #5674

Props Offereins

Note: See TracTickets for help on using tickets.