Skip to content

Commit a3f03d0

Browse files
committed
[creativecommons#64] display user link profile of the chosen voucher in applicant form
1 parent c12c7cb commit a3f03d0

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

plugins/cc-global-network/includes/format-applicant-profile.php

+10
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,16 @@ function ccgn_applicant_display_name_formatted ( $applicant_id ) {
250250
}
251251
}
252252

253+
function ccgn_get_ajax_public_user_url() {
254+
$user_id = esc_attr($_POST['user_id']);
255+
$user_link = bp_core_get_userlink($user_id, false, true);
256+
echo $user_link;
257+
exit(0);
258+
}
259+
260+
add_action('wp_ajax_nopriv_get_public_user_url', 'ccgn_get_ajax_public_user_url');
261+
add_action('wp_ajax_get_public_user_url', 'ccgn_get_ajax_public_user_url');
262+
253263
///////////////////////////////////////////////////////////////////////////////
254264
// Log ask for Clarification
255265
///////////////////////////////////////////////////////////////////////////////

themes/cc-commoners/assets/css/extra.css

+4
Original file line numberDiff line numberDiff line change
@@ -368,4 +368,8 @@ table.ccgn-profile tr td.title {
368368
}
369369
.block-area .entry-content {
370370
min-height: 20rem;
371+
}
372+
.voucher_profile_link {
373+
margin-left: 1rem;
374+
font-size: .9rem;
371375
}

themes/cc-commoners/assets/js/cc-commoners.js

+26-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,22 @@ var swiper = new Swiper('.swiper-container', {
4444

4545

4646
jQuery(document).ready(function($){
47-
47+
var getUserPublicUrl = function(userId, targetId) {
48+
$.ajax({
49+
url: Ajax.url,
50+
type: 'POST',
51+
data: {
52+
action: 'get_public_user_url',
53+
user_id: userId
54+
},
55+
success: function (data) {
56+
var target = $('#'+targetId),
57+
link = '<a href="'+data+'" target="_blank" class="voucher_profile_link">View User profile</a>';
58+
target.html('');
59+
target.html(link);
60+
}
61+
});
62+
}
4863

4964
$("body.page-template-page-faqs .item-acordion h2").toggleClickV2(function(e){
5065

@@ -113,22 +128,30 @@ jQuery(document).ready(function($){
113128
*/
114129
$('#input_41_1').on('change', function(e){
115130
var thisSelect = $(this),
131+
thisSelectId = thisSelect.attr('id'),
116132
selectedValue = thisSelect.val(),
117133
otherSelectId = '#input_41_2',
118-
otherSelect = $(otherSelectId);
134+
otherSelect = $(otherSelectId),
135+
profileUrlId = thisSelectId + '_profile_url';
119136

137+
$('<span id="'+profileUrlId+'"></span>').insertAfter('#'+thisSelectId+'_chosen');
120138
$(otherSelectId+' option[disabled="disabled"]').removeAttr('disabled');
121139
$(otherSelectId+' option[value="' + selectedValue + '"]').attr('disabled', 'disabled');
122140
otherSelect.trigger("chosen:updated");
141+
getUserPublicUrl(selectedValue,profileUrlId);
123142
});
124143
$('#input_41_2').on('change', function (e) {
125144
var thisSelect = $(this),
145+
thisSelectId = thisSelect.attr('id'),
126146
selectedValue = thisSelect.val(),
127147
otherSelectId = '#input_41_1',
128-
otherSelect = $(otherSelectId);
148+
otherSelect = $(otherSelectId),
149+
profileUrlId = thisSelectId + '_profile_url';
129150

151+
$('<span id="' + profileUrlId + '"></span>').insertAfter('#'+thisSelectId+'_chosen');
130152
$(otherSelectId + ' option[disabled="disabled"]').removeAttr('disabled');
131153
$(otherSelectId + ' option[value="' + selectedValue + '"]').attr('disabled', 'disabled');
132154
otherSelect.trigger("chosen:updated");
155+
getUserPublicUrl(selectedValue, profileUrlId);
133156
});
134157
});

0 commit comments

Comments
 (0)