Hello All I was wondering if someone could help me out. I have multiple users for my blog and they are allowed to create posts. I would like to create a mailto: link on the single.php post for that specific post type. I would like the mailto: email to be the author's email of that specific posts so that a viewer could email the author of the post.
I am aware that wordpress has the function:
<?php $user_email = get_the_author_meta('user_email'); ?>
this function stores the data, i would really appreciate it if someone could help me display a mailto: link with this function.
You can simply echo the value where you need it. For example:
Click here to email author
Or, more readable:
<?php
$user_email = get_the_author_meta('user_email');
echo 'Click here to email author';
?>
Related
i am using CPT UI for custom post type and ACF custom fields.
i have created custom post type (companies) and linked to its custom fields. In admin everything is okay. I want to display this in front end. The user can be enter the company details also. How can i display this in front end ?
<?php
$id = get_the_ID();
$data = get_field('custom_field_name', $id);
echo $data;
?>
Obviously this will need a lot of refinement to look good but that's the basics on how to retrieve data from an ACF field. You may need to var_dump($data); in order to figure out how to get the part you want (if it's not just storing a string). Without more details on what you're doing that's a good an answer as I can give you.
I have a problem with usersultra plugin for wordpress.
I have created a template page for search, but i only want to display it for the client who is logged in, how can i use usersultra for this case.
Secondly when i check 'Only Logged in Users' checkbox in page settings it displays the content of my page and form of registration at the same time.
Please how can i resolve this problem.
EDIT :
this is what am trying but it doesn't work
<?php echo do_shortcode("[usersultra_protect_content display_rule='logged_in_based' custom_message_loggedin='Only Logged in users can see the content']
<b>myfield :</b><?php the_field('myfield');?>
[/usersultra_protect_content]"); ?>
it only shows the text not the value.
EDIT 2 :
it worked with the code Ahmed provided
<?php echo do_shortcode("[usersultra_protect_content display_rule='logged_in_based' custom_message_loggedin='Only Logged in users can see the content']
<b>myfield :</b>".the_field('myfield')."
[/usersultra_protect_content]"); ?>
You can do that via this shortcode,
<?php echo do_shortcode("[usersultra_protect_content display_rule='logged_in_based' custom_message_loggedin='Only Logged in users can see the content']Your private content here [/usersultra_protect_content]"); ?>
The shortcode is listed here on documentation page : https://usersultra.com/userultra/
I have a form where user add his email address, I’m trying to prevent users to enter there email many times. I use "contact form to database plugin" to save email address and export them to excel. while searching on internet I found this solution (link below) but I can’t get it work can you help me please :
https://cfdbplugin.com/?page_id=904
Thanks
I found the solution,
in the line where you put the name of the form you should put the title of the form (line bellow ) :
$formName = 'email_form'; // Change to name of the form containing this field
so, for exemple if we have created with the contact form 7 a form here is the shortcode that we will have :
<?php echo do_shortcode( '[contact-form-7 id="69" title="Email_form" html_name="my_form"]' ); ?>
what I did is I put the value of html_name in the script of CFDB but when I changed to the value of title it works
I am looking to display only certain fields from the User Profiles Made Easy Plugin on my page. The users 'Display Name' for example, I don't need the full profile, just the display name. Can anyone point me in the right direction on how to do this?
I have looked at the docs, posted on the plugin forum and trawled the Internet for help but I can't find any.
Currently I can only get the whole profile to display, even when I pass the display_name in.
<?php echo do_shortcode("[upme view=display_name]"); ?>
Any help would be appreciated.
Thanks.
I managed to accomplish this using the following code:
<?php
$display_name = get_user_meta($user_ID, 'display_name');
$description = get_user_meta($user_ID, 'description');
?>
Then I pulled the value from the array using:
<?php echo $display_name[0]; ?>
I am no php expert so I am not sure if this is efficient (or even correct), but it seemed to work for me.
Is there an easy way to password protect an archive and single posts of a custom post type?
I found this article on password protecting single posts, but am still lost on the archive loop. I would want it only display the password box until the user has logged in.
https://wordpress.stackexchange.com/questions/4952/forcing-all-posts-associated-with-a-custom-post-type-to-be-private
Thanks,
The only way I've found to quickly password-protect the archive is by creating a template that retrieves the custom post type data and associating it with a page that can be password protected.
http://codex.wordpress.org/Page_Templates
Once that page is password protected, you find the post ID to apply it to the single-{your_custom_post_type}.php like so:
<?php
if ( !post_password_required('{protected_post_id}') ) : ?>
//protected content here
<?php else:
//show the password form of the protected page
echo get_the_password_form('{protected_post_id}');
endif; ?>
This saves you from having to password-protect every post under your custom post type.
For single pages you could just edit single.php and add something along the lines of:
<?php
if ( is_user_logged_in() ) {
// Show Post to Logged in User
}
else {
//Show password field
}
?>
If like you mentioned you are using a custom post type or an archive template you could apply the same method as above to single-[custom-post-type-name].php or archive.php