David
Forum Replies Created
-
AuthorPosts
-
DavidParticipant
Ok, thanks very much for your help.
DavidParticipantHi Shamim,
Thanks very much. The meta query is working but I am also trying to orderby the meta value. I have tried everything I can think of but it won’t work. This is what I have:
add_filter( 'fep_message_query_args', 'totalsortjg');
function totalsortjg( $args ) {
if (in_array('subscriber', wp_get_current_user()->roles) && isset($_GET['partotal'])) {
$args['meta_query'][] = ['totalsort' => [
'key' => 'total_sort',
'value' => 1,
'compare' => '>',
'type' => 'NUMERIC'
]];
$args['orderby'] = ['totalsort' => 'DESC'];
}
return $args;
}
Thanks for the help.
DavidParticipantOk, I have tried this and the meta_key is definitely there but the following code is not doing anything:
add_filter( 'fep_message_query_args', 'totalsortjg');
function totalsortjg( $args ) {
if (in_array('subscriber', wp_get_current_user()->roles) && isset($_GET['partotal'])) {
$args['meta_key'] = 'total_sort';
}
return $args;
}
I am expecting to only see messages with the meta_key present. Any help is appreciated.
DavidParticipantOk, I think I have figured this out! I thought it was using the parent message which is the one with the meta_key but of course it is not the parent, it is the child message that is being queried and these do not have the meta keys. I will have to rethink this.
DavidParticipantI have also tried this but I just cannot make it work.
add_filter( 'fep_message_query_args', function( $args, $user_id ) {
if (in_array('subscriber', wp_get_current_user()->roles) && isset($_GET['partotal'])) {
unset( $args['orderby'], $args['meta_key'], $args['order'] );
$args['meta_key'] = 'parent_total';
$args['orderby'] = 'meta_value_num';
$args['order'] = 'DESC';
return $args;
} else {
return $args;
}
}, 10, 2 );
DavidParticipantNo, thought I had figured it out but still not working. I just want to query the messagebox by a meta key and then orderby that meta key number. Any help is appreciated.
DavidParticipantSorry, figured it out. Answer for anyone needing it in the future:
add_filter( 'fep_message_query_args', function( $args, $user_id ) {
if (in_array('subscriber', wp_get_current_user()->roles) && isset($_GET['partotal'])) {
$args = array(
'meta_query' => array(
array(
'key' => 'parent_currency',
'value' => 'LKR',
'compare' => '=',
),
),
'orderby' => 'meta_value',
'order' => 'DESC'
);
$args['participant_query'][] = array(
'mgs_participant' => $user_id);
return $args;
} else {
return $args;
}
}, 10, 2 );
DavidParticipantYes, I can probably manage the error message myself with my limited skills. I was thinking though that it could be a useful addition to the core plugin. I am not sure the thread needs to dynamically update, maybe just a link in the error message which refreshes the page would work ok.
DavidParticipantGreat thanks very much for your quick reply.
DavidParticipantJust to add that I am trying to achieve something like this:
‘created_before’ => ‘1 year ago’
like I would do in a date_query.
DavidParticipantHi Shamim,
I am using this code now for the shortcode-newmessage. However, I would like to make it specific to the page or post that I am on. This is because I am using the shortcode in three different places and I only want to redirect from one of those. Is it possible? I tried adding “is_page(‘test’) but it didn’t work.
Thanks for any help.
DavidParticipantOk figured it out. Full code is here if it helps anyone in the future:
if ( isset($_GET['id']) && (isset($_GET['your_action']) == 'delete')) {
$id = $_GET['id'];
if ( $id && in_array( get_current_user_id(), fep_get_participants( $id, true ) ) && fep_get_message_status( $id ) == 'publish' ) {
fep_delete_message($_GET['id']);
delete_user_option( get_current_user_id(), '_fep_user_message_count',true );
}
}
DavidParticipantHi Shamim,
I have managed to do achieve this but one problem is that fep_get_user_message_count( “total” ) is sometimes not updating after the message is deleted.
Can I update this value somehow? It works ok when I delete a message normally but I can’t see any difference.
Thanks for any help.
October 11, 2021 at 10:38 pm in reply to: Notification emails using fep_send_message function #43778DavidParticipantThe plugin is Calculated Fields Form. The code fires immediately after a form is submitted. After that is complete there is a redirect to another page. I do not know anymore than this without asking the plugin authors. I do have an option to use the form submitted email to send the notification instead now that I know the normal fep notification is not going. Thanks for the clarification.
October 10, 2021 at 10:15 pm in reply to: Notification emails using fep_send_message function #43773DavidParticipantHi Shamim,
Thanks for your quick reply.
I can confirm that if I use your code in functions.php it works fine and the notification email is sent.
However, I am using it a bit differently. I am using it in relation to another plugin. The code is as follows:
if($params['formid'] == 69) {if ( get_current_user_id() < 1 )
return;
if ( ! function_exists( 'fep_send_message' ) )
return;// Prepare message data
$message = array(
'message_title' => 'New Enquiry', //change with message title
'message_content' => $params['fieldname42'], //change with message content
'message_to_id' => 8037
);$override = array(
'mgs_author' => get_current_user_id(), //change with message sender id
);// Send message
fep_send_message( $message, $override );}
When I submit the form on the other plugin the message sends ok but the notification email does not send. I have checked the email log and nothing is sending.
Can I use it like this? I cannot really see why it does not work.
Thanks for any further help..
-
AuthorPosts