Hello @urshadow,
Try this code:
function dco_init() {
$dco_ca = dco_ca();
remove_action( 'comment_form_submit_field', array( $dco_ca, 'add_attachment_field' ) );
add_action( 'comment_form_submit_field', array( $dco_ca, 'add_attachment_field' ), 100 );
}
add_action( 'init', 'dco_init' );
You can add this snippet into functions.php file of your active theme or add it in your custom plugin or use special plugins, such as, Code Snippets.
Thanks @denisco
The above code has placed it under cookie consent. If it’s easily possible to go above cookie consent then plz share, else this is fine as well.
Screenshot: https://www.screencast.com/t/3LLLt83b
Thanks once again.
Let’s try this code:
function dco_init() {
$dco_ca = dco_ca();
remove_action( 'comment_form_submit_field', array( $dco_ca, 'add_attachment_field' ) );
add_filter( 'comment_form_field_cookies', array( $dco_ca, 'add_attachment_field' ) );
}
add_action( 'init', 'dco_init' );
Screenshot: https://i.imgur.com/3IydXex.png
Thanks @denisco
This positioned the attachment section above the cookies consent but an unanticipated issue happened. As the cookies consent is not visible to the logged-in user thus the attachment section disappeared for the logged-in user:
Screenshot: https://www.screencast.com/t/1DiVoppYY1Y
As the comments box is visible to both logged-in and non-logged-in users thus I tried the following code:
function dco_init() {
$dco_ca = dco_ca();
remove_action( 'comment_form_submit_field', array( $dco_ca, 'add_attachment_field' ) );
add_filter( 'comment_form_field_comment', array( $dco_ca, 'add_attachment_field' ) );
}
add_action( 'init', 'dco_init' );
The attachment section appears for all but it displays above the comments box.
Screenshot: https://www.screencast.com/t/3X6P6LxVQIf
Can we move it down the comments box, I think that would be the ideal position for the attachment section.
You can use is_user_logged_in function for it.
function dco_init() {
$dco_ca = dco_ca();
remove_action( 'comment_form_submit_field', array( $dco_ca, 'add_attachment_field' ) );
if( is_user_logged_in() ) {
add_action( 'comment_form_submit_field', array( $dco_ca, 'add_attachment_field' ), 100 );
} else {
add_filter( 'comment_form_field_cookies', array( $dco_ca, 'add_attachment_field' ) );
}
}
add_action( 'init', 'dco_init' );
Perfect!
Thanks @denisco for the great support!